Frage

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

War es hilfreich?

Lösung

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.

Andere Tipps

This will work across browsers because when you send a different URL altogether, which hasn't been seen before, the browser shouldn't use a cached response, as it can't verify it is correct.

RFC-2616

13.1.1 Cache Correctness

A correct cache MUST respond to a request with the most up-to-date response held by the cache that is appropriate to the request


If you are still worried and want to stick to something more clearly defined in the standard, you could also set the Last-Modified header for those files, when sending them out.

Browsers send out a request containing If-Modified-Since and when they request an older version, the server won't return a 304 Not Modified, and will return a fresh copy, preventing the cached file being used.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top