Firefox CSS Issues

Published on 13 August 2005 in , , , , ,

Well it’s taken a year and I’ve finally fixed most of the issues with the CSS on my sites, and Firefox not displaying it, thus leaving the site looking plain and white until you refreshed.

You can read the original post from 2004 about the gory details and the follow up where I thought I’d fixed it.

My solution of making the CSS files into PHP files and trying not to get them cached, stopped working on some sites soon after.

Finally, about a month ago I discovered what the problem was, thanks to trawling through Apache’s bug list where I found bug 30278.

There was a bug in Apache v2.0.50 (which the webserver I use, currently runs) which was serving cached versions of the file up with the wrong mime type, thus causing the problems. My attempts at fixing via PHP were (in some cases) also getting cached hence that fix wasn’t working either.

The solution is extremely simple – upgrade Apache. But if, like me, you’re not able to do that, there is a solution. Ditch all that PHP stuff I suggested, and when calling your CSS file, bung ?1 at the end – for example:

<style type="text/css">@import url(/build/style/scumble.css?1);</style>


<link href="/build/style/scumble.css?1" rel="stylesheet" type="text/css">

Or similar. What follows the question mark is arbitary (I just used a one), but needs to be there – just having the question mark doesn’t work.

What’s happening now is that mod_cache in Apache sees the file request, believes the CSS file to be dynamic (i.e liable to change each visit), and therefore doesn’t cache it.

Now in reality the file isn’t changing – its just a static CSS file after all – so you’ll be making your webserver less efficient, but the impact won’t be huge unless you’re on a really busy site. And besides, you’re punters will be happier cos they actually get to see the site as it’s designed, rather than as just a plain screen with Times New Roman text!