browser cache not getting updated even when the files are modified - html

Whenever I update my site with new files, I need to clear the cache every time to see the changes, which I don't want to do it...I have set expiration duration as 1 day,
Can anybody explain where is it going wrong and what's the solution?.
Thanks in advance

You need to add random (or version-like) parameter to your scripts/css/images, like:
<script>document.write('<script src="script_path?' + Math.random() + '"\><\/script>');</script>
wich makes browser to request like script_path?0.611818 so script will nave get cached (actually it will, but always would be requested a new copy).
Another way is adding version like parameter, e.g. current version of your web app is 5, so you do:
<script>document.write('<script src="script_path?' + your_version + '"\><\/script>');</script>
After each version you increase your_version parameter value by on or smth like that
p.s.
Examples are shown in js, but you will do it using your backend language

To make the browser load a file http://example.com/file.ext from server every time instead of from the cache, change the client code to point to http://example.com/file.ext?<random value>. Every time you change the file, change the random value in the link.

Related

JMeter - HTTP Request Path maximum size to display text

I have a test in JMeter to update details which have many query parameters
I prefer sending them in path instead of create line for each parameter,
The problem that I have more than 256 characters overall (~450) which make Path field not displaying the text content:
Is there a max parameter I can change? Am I'm doing something wrong or it's a bug/limitation in JMeter/Swing component?
As per JMeter version 3.3 you can scroll "Path" with keyboard or mouse, if you don't see a part of your query string - don't worry, it's still there, you can verify it using View Results Tree listener.
Another option is investing into a higher-resolution display.
Third option is looking into UrlConfigGui class, there is a following line there:
path = new JLabeledTextField(JMeterUtils.getResString("path"), 80); //$NON-NLS-1$
You can try playing with this 80 number, however it will require recompiling JMeter and given the nature of your request I strongly doubt you're capable of this
Since JMeter 4.0 I don't have this issue, I can write in field any number of characters and it's still visible.
I didn't find specific change in version 4, but there were UX improvements that may fix this issue.

Scan an area of a web page's source code for changes while reporting it?

this is one heck of a confusing question to ask so here it goes. Firstly, I'm not asking you to write me any code I just need help going in the right direction for what I'm trying to achieve here. Basically the task is this, I want to scan a select area of a web page's source code for changes and if something does change, I want to report it somewhere (like a console or something). However, I do not want just a notification of change, I also want what the change is/was. I've been looking into things like jsoup but I am still struggling to even find out what this is called.
Any pointers would be insanely appreciated. Thanks, Optimistic.
Here are some steps assuming this is from a node.js project:
Get the URL for the specific script file you're looking for a change in.
Using the request() module, fetch that URL.
Break the data up into lines (probably using .split()).
Find the specific line you are looking for either by counting line numbers of by searching for some representative text in that line.
Using some sort of search in that line (perhaps a regex), find the current value of the exact item in that line you are looking for.
Save the current value.
Then, at some future time, repeat this whole process and compare what you find to the previous value.
If this is being done from a browser instead of node.js, then use an Ajax call to retrieve the file. If the file is on another domain from your web page and that domain does not permit cross-origin requests, then you cannot solve this problem in an automated fashion from a browser in your own web page.
Here is how I would do it with Jsoup:
Document doc = Jsoup.connect(url).get();
String scriptCssQuery = "script"; // Tune this CSS query to find THE script you need.
Element script = doc.select(scriptCssQuery).first();
if (script != null) {
String scriptLines = script.html();
// Store the changing line somewhere and compare it to its previous value...
}

as3 store an external variable and keep it

I dont know if this is possible, but i have an SWF file which i want it to get info from an xml file only one time and then store it(keep it) there until a "newer" data will push into it
I know it sounds stupid but maybe there is a solution i don't know of...
1) i don't want to load the xml every time because of loads of traffic we have(a lot...will cost a lot to refresh everytime from amazon s3)
but how do we get a newer data without checking the external xml file?
2) if there was a way to broadcast(to "ping") to the swf that an update of the xml is ready to load....
if anything i believe there should be an AS3 script for that.
thanks!
but how do we get a newer data without checking the external xml file?
You could implement data file versioning. For example: urlToXmlData + "?version=" + myCurrentVesion As soon you ship new version of the application with extended data, it will work. It's global solution, so every new version of your product will work with latest data.
As for ping, you could create update strategy, for example: link is valid for 1 day. Idea is the same, concatenate stuff to the link, so browser will evaluate it as new: urlToXmlData + "?stamp=" + timestampForToday Tomorrow will be another timestamp, and browser will download updated version.
Use second xml which will contain the version first xml
I think you don't get the real subject.
You can't update a flash project without using any external update platform.
Because you cannot save all new XML data to a shared object because of "limitation of mb per data", so, flash going to delete all loaded data when application closed.
You cannot make a "permament update" in flash for "big files"...
BUT
You can update your main swf file with "EMBEDDED XML" files. Only that keeps your data updated when application is closed.
BUT that's not enough alone, also you need a "PRE-CHECK for Version of SWF" file, and that's what you can't do alone. You need a web platform featuring that way.
Mochi's "Live Updates" was offering that, but i couldn't make it work. But mochi is shutdown now... So forget about it...
I understand that your XML is BIG and you want to save trafic.
But how about small calls ?
You can have a call just to get the MD5 of your xml which is stored on the server.
Something like: myserver.com/getMD5
Once the server will return you a different md5 than the one you have already stored, then you reload xml and save new MD5.

modified date changes after upload

I am integrating with the v2 Box rest api from an iOS app.
When I upload a file I cache it's modified date (as reported by Box in the return JSON)
Sometime later, I request the folder contents and check the modified date on the file (to see if it's changed since I last uploaded.) Depending upon how long I wait, the modified date changes - wtf!!!
If I request the folder contents immediately (msecs) after upload then the modified date is as it was after upload. If I wait 3 or 4 seconds then the date changes (by 1 second typically.)
Anyone from Box know why this might be - and how to fix it?
I don't know the answer to your particular question, but this caught my eye:
I ... check the modified date on the file (to see if it's changed since I last uploaded.)
If you're primarily concerned with detecting changes, then you might instead consider using the etag or version properties of the file object. They are designed for exactly this purpose.

Set file date with managed code in WP8

Is it possible to change the file creation date or file last write date from managed code in WP8?
I can read the date stamps using FileInfo, but these properties are read only. Using native code it looks like I can use the SetFileInformationByHandle api. My project does use native code so I can add a little helper function, but this seems like a lot of over kill.
Reason: I've got an online multiplayer game (4sFear) that lets people upload their own avatars. Currently I just set the source of an image to the http address of the avatar but I would like to be a little smart and cache the images locally. I can return the last time an avatar was updated before it needs to be displayed. I know I can store the dates that the avatars were updated separately, but it makes sense that I should just be able to set the last write date of file after creating it.
The SetFileInformationByHandle API is supported via DLL api-ms-win-core-file-l1-2-0.dll More info here: https://msdn.microsoft.com/library/windows/apps/jj662956%28v=vs.105%29.aspx#BKMK_ListofsupportedWin32APIs which can be called using DLLImports.
I don't have a machine to test but you could try the following: How to update the change time of a file from c#?