Best way to burst static file cache

Ed W lists at
Sun Oct 2 13:15:46 UTC 2011

On 02/10/2011 13:34, tcbarrett wrote:
> kaspars Wrote:
> -------------------------------------------------------
>> Well, if you set cache to expire 30 years from now
>> the browser should honor that, that is if no
>> Last-Modified is set.
> I have it set to 30m (30 minutes, right?). If I update, for example,
> some css files and then a do a hard refresh on a) a Mac then I get the
> new css or b) Windows 7 then I keep getting the cached css files.
> Is there any technique to burst this caching. It might not be a 'pure
> nginx' solution, but anything that could be supported by an nginx config
> setting?

What everyone else does is set the URLs to be unique and then change the
url when the asset is updated.  eg a simple example which rails uses and
arguably isn't perfect would be:


The random string after the ? could be generated in various ways, eg
incrementing counter or it could be the epoch time of the file mtime (ie
age in seconds)

Now you can set expire time to 30 years and when the asset is updated
you simply arrange for the url to be updated in the html and a "new"
image is pulled down

Implementation left to the reader as an exercise...

Ed W

More information about the nginx mailing list