Reloading CSS, etc

18 September 2007

As I deployed the new version of the K-Prep site, I was having trouble getting clients to get the new versions of the CSS files. It stayed cached in the browsers.

To make sure it doesn't happen again, I've dropped a configuration into my Apache 2 server to expire CSS files immediately, and require the browser to at least ask the server if there's been an update. This doesn't make the server unnecessarily transfer the file with every request -- it returns an HTTP 304 code to indicate that the cached copy is still up-to-date. I should probably do something similar for other notoriously cached files, like scripts.

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css A0

Filed Under: Computers Linux Blog-Code