How can I make sure the client browser cache is updated after deploying new CSS or JavaScript files?
I use Microsoft ASP.NET Web Optimization Framework
As you know, it can combine all JS / CSS into one file. You can define the name of the output file in config and make sure the custom browser will receive JS / CSS updates, it adds a parameter likev=yUVjELgc9foFnhZgsvMfx2DhVRLKWK-w69IoCVhJ_aM1
The link looks like this:
src="/scripts/js/jquery?v=yUVjELgc9foFnhZgsvMfx2DhVRLKWK-w69IoCVhJ_aM1"
I heard that not all browsers support this setting and do not update the cache.
Can I be sure that all browsers will update the cache using this approach, or will I have to manually generate a new filename? Is there a table where I can see browsers that doesn't support this?
thank
source to share
I heard that not all browsers support this setting and do not update the cache.
The browser doesn't need to "support" it.
The goal is to change the url to script.
Since the URL is different, the resource with that URL will not be cached.
In order for the technique to fail, the browser would have to have a serious error (in which it used special query strings to handle the cache). This would break huge amounts of the internet like (for example) google search for "kittens" and then a search for "puppies" would show cached kitten results for a puppy search.
source to share
This one will work in browsers, because when you submit a different url altogether that hasn't been seen before, the browser shouldn't use the cached response, since it can't verify it's correct.
13.1.1 Correcting the cache
The correct cache MUST respond to the request with the most recent response stored in the cache ,
If you are still concerned and want to stick to something more clearly defined in the standard, you could set Last-Modified
these files as well when you submit them.
Browsers send a request containing If-Modified-Since
, and when they request an older version, the server will not return 304 Not Modified and will return a new copy, preventing the cached file from being used.
source to share