Steve Perks Steve Perks - 1 year ago 78
CSS Question

Does anyone know of any issues using a querystring within a CSS file?

We're making changes to our main sprite and I'm debating the benefits of either changing its name completely or adding a query string to the end.

There's logic to keeping the old version to support Google cache,, etc., but it'd also be much cleaner on our system if I was to just edit the file and add a query string to the CSS image call:

#element-id { background-image: url('my-sprite.png?version1'); }

My question is, does anyone know of any browser issues with using a query string cache buster in a CSS file?

My suspicion is that browsers handle css image requests the same way whether it's from CSS files or via HTML, so, so long as my server is expressing header information properly I should be OK.

Answer Source

Unless the browser is seriously broken, there should be nothing wrong. Suppose you wanted to use a dynamic file, such as url('/layout.php?section=1') or something. Query strings are kind of required there, so if the browser didn't work it'd be broken quite badly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download