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

Posted in on 21 January 2009

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

Related Posts

Comments

  1. Daniel Botting 14 February 2009, 23:57 1

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

    Many thanks

  2. Clive Walker 15 February 2009, 10:26 2

    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].

Textile Help
Stop looking at my bottom