Search code examples
.netiisbrowser-cachebundling-and-minificationweb-optimization

How to ensure that client browser cache has been refreshed after deploying new CSS or JavaScript files?


I'm using Microsoft ASP.NET Web Optimization Framework

As you may know, it can concatenate all JS/CSS into single file. You can define output file name in config and to ensure that user browser will pickup updates JS/CSS it adds parameter like v=yUVjELgc9foFnhZgsvMfx2DhVRLKWK-w69IoCVhJ_aM1

Link looks like:

src="/scripts/js/jquery?v=yUVjELgc9foFnhZgsvMfx2DhVRLKWK-w69IoCVhJ_aM1"

I heard that not all browsers supports that parameter and not refreshing cache.

Can I be sure, that all browsers will update cache using this approach or I have to manually generate new file name? Is there any table, where I can see browsers, that doesn't support that?

Thank you


Solution

  • I heard that not all browsers supports that parameter and not refreshing cache.

    Browsers don't need to "support" it.

    It's purpose is to change the URL to the script.

    Since the URL is different, the resource at that URL won't have been cached.

    For the technique to fail to work the browser would have to have a severe bug (in which it special cased query strings for cache handling). This would break vast amounts of the web as (for example) searching google for "kittens" and then searching for "puppies" would show the cached kitten results for the puppy search.