How can you be sure the latest CSS stylesheet is loaded by the Browser?
July 22, 2013
Hi,
The problem:
You keep updating your CSS stylesheet but the browser loads the old one from cache and so when a returning visitor loads the site, the layout gets screwed up. This is basically a CSS caching problem.
Solution:
Since the browser won’t recognize an update in the CSS stylesheet, you can basically “fool” the browser into thinking you’ve added a new stylesheet.You can do this by renaming the CSS stylesheet by adding a ? after the file extension, followed by a version number (or anything you want):
<link href="style.css?v=24" rel="stylesheet" type="text/css" /> |
Then you can be sure that every client will reload the CSS rather than use a cached version. The server will ignore the parameter (ex: v=24) and load the stylesheet like normal.
Thanks to Big Roberto for this tip.
Stefan Mischook
csstutorial.net