Invalidate cache for static files?
black at scene-si.org
Mon Jul 21 17:22:13 MSD 2008
That is a tricky thing with various browsers. The best sollution I've
experienced for this, is to assume the files are cached indefinetly, and
you modify somekind of unique folder, to the same location. Ie:
/css/[0-9]+\.[0-9]+/(.+) => /css/real/$1 (somebody else will have to do
a valid nginx rewrite rule)
This way the browser always loads the new files, as long as you modify
the dirname in your software, when you want to update the clients.
/css/1.00/style.css => /css/real/style.css
/css/1.01/style.css => /css/real/style.css
Just add another + 0.01 to your application, when you want to reload
with the new css/js files.
With a purely development server, you can use a dynamic variable (php's
time() function for example) in the directory name, so that it always
reloads the relevant code.
This should be a more elegant and a cross-platform sollutions for all
browsers. In fact, i've seen it been recommended several times.
Phillip B Oldham wrote:
> What would be the simplest way to invalidate browser cache of static
> files served by nginx?
> For instance, we have a website which is in active development. We get
> a reasonable amount of traffic, but we often get complaints when we
> update the live files because some browsers are working with a mix of
> fresh (live) and stale (cached) js/css files. We'd like to
> inform/force browsers that the file is new and should be updated.
More information about the nginx