Question

Are parameterized version queries, such as style.css?v=1234, for css/js superfluous when etags are sent by the server?

Was it helpful?

Solution

(This question ranked quite high for me in Google, so I figured I'd add a belated answer for anyone still looking.)

You are correct. Appending version numbers as a query string is a last resort for resource versioning, as some proxy services (notably Squid 3 and older) do not cache files with a query string or disregard the query string.

It's commonly thought that some older browsers can't handle caching resources with query strings but I have yet to see this urban myth confirmed.

When you can't configure the server headers, you would be best off appending a version number in the filename itself, so don't do this:

css.css?v=2.0

But do this instead:

css-2.0.css

Of course, if you are able to change headers, use them! Etag has been supported since the '90s so that's a solid bet for resource versioning. There's also Expires, Cache-Control and Last-Modified. You should use a combination (but not all) of these headers tailored to your application's needs.

For good practical examples, I advise reading more about HTTP headers and caching at Google Developers and Yahoo! Developer Network. They should know, after all.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top