[thelist] CSS caching

Max Schwanekamp lists at neptunewebworks.com
Mon Apr 24 15:23:27 CDT 2006

> From: Nick Daverin
> But many people in our organization report problems of our 
> old css being applied. I just added a no-caching header to 
> our page, which should help with future roll-outs, right?

To the page, or to the CSS file?  Keep in mind that the cache headers for a
particular page apply to that page, not necessarily to external files.
You're apparently using PHP, so you can use header() to set the expiration,
pragma, etc headers on the css file itself, if you want to go that way.

> Is 
> there a way to easily have browsers seek out the new css page now?

Add a query string to the css call, or change the filename.  E.g.:
<link rel="stylesheet" media="all" href="/css/web.css?version=1234" />
Or add it dynamically with PHP, e.g.:
<link rel="stylesheet" media="all" href="/css/web.css?v=<?php echo time();
?>" />
(you might use date() to make it change every 10 minutes or something
instead of every second).

Max Schwanekamp

More information about the thelist mailing list