you are
  here > Articles > Web Component Architecture

General Web Issues > Firefox CSS Issue on Apache
Published: 2006-03-17

During our development process we test our web applications on a variety of different browsers. Recently we have had problems with the CSS stylesheet using Firefox. Searching the web provided a number of different solutions to this problem, none of which turned out to help.

By sniffing the traffic we were able to determine that the web server was changing the Content-Type header in the http response from text/css to text/plain. Further investigation showed that the server (Apache) was using mod_cache. The web pages are written in XHTML, and when Firefox saw the CSS file presented as text/plain, it decided to discard the file rather than use it anyway. Internet Explorer does not exhibit this behavior.

While there may be many ways to get around this problem on the browser itself, we decided to attack the problem at its source, in the mod_cache configuration. It turns out that on the first request, Apache serves the page with the correct content type, and mod_cache caches it as well. Subsequently the page is served from mod_cache, however it doesn't necessarily use the negotiated content type from the previous access. Instead it uses a content type it determines from its own interpretation of how that content should be presented, possibly based on alternative negotiated types. For further information see the "Notes on Caching" at the bottom of the page: http://httpd.apache.org/docs/2.0/content-negotiation.html

The solution to the problem for us was to disable caching on the directory serving the CSS pages. Other solutions are possible using more granular control mechanisms, such as the file type. On our server, the mod_cache configuration is in /etc/httpd/conf.d/55_mod_cache.conf. To solve the problem we added the following line to this file:

CacheDisable /assets/styles

After restarting the httpd process the problem disappeared.

Hopefully this article has proven useful. If you would like to provide any feedback, or have other questions you would like to see addressed, you can contact us directly at feedback@azgaard.com

  Copyright © 2005-2008 Azgaard Systems Inc. - All Rights Reserved.