Is it the filename or the whole URL used as a key in browser caches?

Posted by Richard Turner on Stack Overflow See other posts from Stack Overflow or by Richard Turner
Published on 2008-09-17T14:44:06Z Indexed on 2011/03/20 0:10 UTC
Read the original article Hit count: 158

Filed under:
|
|
|
|

It's common to want browsers to cache resources - JavaScript, CSS, images, etc. until there is a new version available, and then ensure that the browser fetches and caches the new version instead.

One solution is to embed a version number in the resource's filename, but will placing the resources to be managed in this way in a directory with a revision number in it do the same thing? Is the whole URL to the file used as a key in the browser's cache, or is it just the filename itself and some meta-data?

If my code changes from fetching '/r20/example.js' to '/r21/example.js', can I be sure that revision 20 of example.js was cached, but now revision 21 has been fetched instead and it is now cached?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about url