Is it possible force the browser to fresh the cached CSS? This is not as simple as every request. We have a site that has had stable CSS for a while. However now we need to make some major updates to the CSS. However browser who have cached the CSS will not receive the new CSS for a couple of days causing rendering issues. Is there a way to force refresh of the CSS or are we better just opting for version specific CSS URLs?
A:
The only way would be a bit of javascript causing the browser to refresh such as this.
m.edmondson
2010-10-06 08:35:38
+1
A:
Append a random parameter to the end of the CSS URL included in your HTML.
<link href="normalfile.css?random=123435453" />
That way, your old file name doesn't really change as far as you are concerned, but to a browser it's a brand new resource that must be retrieved.
Tim
2010-10-06 08:36:33
Ah I like the thinking on this one
m.edmondson
2010-10-06 08:37:19
A:
Yu might be able to do it in apache...
<FilesMatch "\.(html|htm|js|css)$">
FileETag None Header unset ETag Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate" Header set Pragma "no-cache" Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
Aaron R
2010-10-06 14:48:59