Reputation: 850
I am updating my site frequently after finishing updates my clients reporting that old images & scripts are getting loaded instead of new ones. I know they are coming from their browser cache but is there any way i can force scripts not to load from cache in server.
I am using nginx with php-fpm.
Upvotes: 5
Views: 14719
Reputation: 71384
You can force HTTP headers to influence the browser caching behavior, however this is probably not a good idea in a production environment where you want caching.
So simply use something like:
expires -1
To force Cache-Control no-cache
header
Check here for more information:
http://wiki.nginx.org/HttpHeadersModule
That being said, I have gotten myself in the habit of just changing image and static files names as I revise them. Perhaps this comes from working with CDN's where this can be incredibly helpful. So say I have static files that I might update often (i.e. they are not part of some specific piece of content). I would name them like:
someimagev1.jpg
someimagev2.jpg
somejs1.js
somejs2.js
etc.
I change values (and links in HTML source) as needed.
Upvotes: 11