Invalidate cache for static files?
denis at arh.cc
Mon Jul 21 19:01:16 MSD 2008
Would it help moving them into a different folder instead of appending
Sent from my iPhone
On 21.7.2008, at 16:55, Tit Petric <black at scene-si.org> wrote:
> Maxim Dounin wrote:
>> On Mon, Jul 21, 2008 at 01:57:06PM +0100, 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
>> Just use normal web development practices, e.g. add "?v=<version>"
>> to js/css urls. Nothing special, nginx is just web server.
> I've tried this before, it is problematic since cache doesn't behave
> correctly and in some cases browsers or even caching proxies in
> front of backend servers never cache the resource, because they
> percieve the link as dynamic.
> Having unique urls, like I suggested in the previous email, solves
> theese problems. Also, you can then set the Expires & Cache-control
> headers for static content far in the future and encourage browser
> caching, since you have an effective method of always reloading them
> without fail. Caches and browsers will keep such objects, while the
> suggested sollution with the "?v=version" will not be cached on many
> of them, since they percieve the url as dynamic and always try a
> reload, ignoring possible Expires & Cache-control headers.
> For a small setup, where you don't care about resources, your
> sollution is mostly fine, but is problematic in the real world with
> tens of thousands of users.
More information about the nginx