Best CSS (and Image) Cache Control


Have you ever updated the markup and CSS for a website but when you load it in your browser it renders incorrectly because of the browser's cache? Have you ever told a co-worker or client that they need to "refresh" or "force refresh?" Chances are then that other visitors to your site are running into this problem, too.

Busy sites like Twitter, Digg, Boing Boing and others use methods to avoid browser cache issues. They find it important for their sites to always display correctly. You too can ensure visitors to your website will always get exactly the version of your style sheets and related image files that you want them to get.

I wrote an article for SitePoint covering solutions to browser cache problems titled "Overcome Your Caching Conundrums".

In the article I cover popular ways to deal with JavaScript and CSS file cache control, as well as a trick-of-the-trade method that will also help you manage your image caching. Hint: Have you ever wished that url() for your background images was relative to the styled-document's location instead of being relative to the stylesheet file's location? I used to feel that way, and it wasn't too long ago that I saw Eric Meyer tweet a similar desire. But now I am actually quite glad that url() works the way it does, and that has to do entirely with CSS cache controlling.

Now go and read the article on SitePoint. I hope you will find it interesting!