Im facing a problem regarding the browser caching of resources. There are a few javascript files, css files that are changed continuously, though the timing is not fixed.
When i update those files on the server, the new files are not loaded and the browser cache needs to be cleared in order to load the new files.
Is there a way, a server or browser setting to tell the browser, when loading a resource, if there are any changes in the server file, load from the server , else use the existing file stored in the browser cache.
Im looking for a solution that would require some browser based / server based configuration, and not something i need to manually do everytime i make an update
Using just a query string to bust cache is not 100% guaranteed: for example some proxy servers will strip any query string on files linked from your html.
A better way is to revision in the uri or filename. I use rewrite rules in apache so that something like:
my.app.com/12345/js/file.js
Is directed to:
htdocs/js/file.js
in the filesystem.
My app then updates the revision number based on source control, but you could do this by hand in your html. With this solution and setting a far-future expires (http 1.0) and max-age (http 1.1) header I get the benefits of permanent client caching via a new uri, and the development ease of the file being in the same place on the filesystem.
Steve Souders on far-future headers:
http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/