Bluehost: Web hosting from $3.95/month. Sign Up

Add a query string to your style sheet link for cache busting

Posted on by Clive Walker in CSS Web Design

I was looking at the UX London website recently and I noticed that their CSS files are referenced with a query string like this:

<link rel="stylesheet" type="text/css" 
          href="/css/screen.css?20090108" media="screen">

The query string [20090108] looks like the date. This seems to be a rather neat method of preventing style sheet caching when your CSS changes. It's not something that I have come across before but it's a clever idea implemented by Jeremy Keith and Natalie Downe at Clearleft.

Update: Confirmed on adactio's Twitter stream

Comments

  • 14 Feb 2009 22:57:49

    Interesting article, does the query string need to be added to every page or just the homepage?

    Many thanks

  • 15 Feb 2009 09:26:35

    You will need to ask the original authors about this but the UX London website uses it on all pages [at least, all the pages I looked at].

Leave a comment

A simple question that helps prevent automated form fillers.

© 2016 Clive Walker