[thelist] css is not loaded with page in Firefox

Mark Kennedy mark at eurogamer.net
Wed Nov 24 11:25:16 CST 2004


Hi there,

I don't know if you're still having this (very weird) problem, but
here's what I've noticed.

http://rebootnb.dimetech.ca/stylereboot.css is sometimes served as
text/css (when it works) and sometimes as text/plain (when it doesn't).

Using 'wget' two times in a row to fetch this file, I got the following
(sorry, it's long):

mark at egg ~
$ wget -S http://rebootnb.dimetech.ca/stylereboot.css
--12:10:31--  http://rebootnb.dimetech.ca/stylereboot.css
            => `stylereboot.css.17'
Resolving rebootnb.dimetech.ca... 142.166.175.13
Connecting to rebootnb.dimetech.ca[142.166.175.13]:80... connected.
HTTP request sent, awaiting response...
  1 HTTP/1.1 200 OK
  2 Date: Tue, 23 Nov 2004 21:13:33 GMT
  3 Server: Apache-AdvancedExtranetServer/2.0.48 (Mandrake Linux/5mdk)
mod_perl/1.99_11 Perl/v5.8.3 mod_ssl/2.0.48 OpenSSL/0.9.7c PHP/4.3.4
  4 Last-Modified: Thu, 18 Nov 2004 23:01:12 GMT
  5 Content-Length: 3512
  6 Content-Type: text/css
  7 ETag: "a8169-db8-5dd3de00"
  8 Accept-Ranges: bytes
  9 Keep-Alive: timeout=15, max=100
10 Connection: Keep-Alive

100%[===================================================================================================================>] 



3,512          4.04K/s

12:10:33 (4.04 KB/s) - `stylereboot.css.17' saved [3512/3512]


mark at egg ~
$ wget -S http://rebootnb.dimetech.ca/stylereboot.css
--12:10:36--  http://rebootnb.dimetech.ca/stylereboot.css
            => `stylereboot.css.18'
Resolving rebootnb.dimetech.ca... 142.166.175.13
Connecting to rebootnb.dimetech.ca[142.166.175.13]:80... connected.
HTTP request sent, awaiting response...
  1 HTTP/1.1 200 OK
  2 Date: Tue, 23 Nov 2004 21:13:38 GMT
  3 Server: Apache-AdvancedExtranetServer/2.0.48 (Mandrake Linux/5mdk)
mod_perl/1.99_11 Perl/v5.8.3 mod_ssl/2.0.48 OpenSSL/0.9.7c PHP/4.3.4
  4 ETag: "a8169-db8-5dd3de00"
  5 Accept-Ranges: bytes
  6 Last-Modified: Thu, 18 Nov 2004 23:01:12 GMT
  7 Content-Length: 3512
  8 Content-Type: text/plain
  9 Age: 5
10 Keep-Alive: timeout=15, max=100
11 Connection: Keep-Alive

100%[===================================================================================================================>] 



3,512          5.30K/s

12:10:37 (5.30 KB/s) - `stylereboot.css.18' saved [3512/3512]

Notice the switch in mime types.  It'll keep being text/plain for a
while.  If I wait 20 secs or so, then try again, it's text/css, then
back to text/plain.  Very bizarre!

It looks like you are not the first person to have this problem (using
same/similar apache versions it seems):

http://www.issociate.de/board/post/136230/Inconsistent_MIME_behavior.html

Here, they seem to discuss playing with Apache's document cache.  BTW,
if this is a unix system, I doubt doing a server reboot would solve much
that an apache restart wouldn't.

If you look carefully at the console dump I pasted, you'll see that the
text/plain file is also served with an extra header: Age: 5.  This seems
to concur with the discussion regarding cache's linked above.

Rob Smith's suggestion of not using @import and forcing the type using
type="text/css" on the link tag is probably the best workaround you've
got until this problem with Apache gets solved.  I'm guessing that just
because the parent style block has it's type forced to text/css, any
@imported block don't get their types forced.

If you really want to use @import for some reason (i.e. hide from old
browsers), then you could use PHP to generate the CSS (or whatever
server side language you happen to use), calling the file
stylereboot.css.php and placing

<?php
	header( "Content-Type: text/css" );
?>

at the top.  If Apache *IS* caching this file in some way, and resetting
it's mime-type, then you could append the date (with seconds) as a query
string to the URL like

@import url( "stylereboot.css.php?20041124114954" );

which, whilst being ignored by the script, will force apache to bypass
its cache.  A similar effect is acheivable by putting a typical no-cache
block at the top of the CSS (after the content-type header) thus:

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-cache");
header("Cache-Control: post-check=0,pre-check=0");
header("Cache-Control: max-age=0");
header("Pragma: no-cache");

That's a bit of an overkill, I'll admit (and probably violates a few
HTTP standards), but it seems to work :-)  In fact, if apache cache
really is a problem, the max-age is probably all you need.

The only problem with this in the long term is that you won't get the
performance benefits from allowing stylesheet caching.

I hope this helps somewhat.  Sorry if it's a bit rambling.

Regards

Mark



Matt Tibbits wrote:
> I'm have a bit of a problem where a page loads in Firefox 1.0 but the CSS
> does not. The page appears as being unformatted. 
> 
>  
> 
> The problem seems to be intermittent, as sometimes the page will load just
> fine.  I should mention that the entire site loads properly in IE6. Also,
> the local copy of the site works fine in Firefox and IE.
> 
>  
> 
> On top of all this when I use the web developer toolbar in Firefox to view
> the css the correct css page is displayed. After I do this, all pages on the
> site work fine.
> 
>  
> 
> I know that the path to my css is correct because all pages work in IE.
> Since everything works locally but does not work from the web server this
> leads me to believe that it could be a problem with the server config, and
> that is a problem. It's a long story, but basically the admin is
> non-existent for this web server. The server is running Apache 1.3 with
> Linux. Whenever I need to configure something I have to telnet to the server
> and change what needs to be changed. This is a problem because I am far from
> being a linux/apache aficionado. 
> 
>  
> 
> One thing that I have verified on the server is that the MIME type for
> text/css is set to css. 
> 
>  
> 
> Does anybody have any idea what else could be the problem?  If you want to
> check out the site to see if you are getting the same issue then the URL is:
> http://rebootnb.dimetech.ca <http://rebootnb.dimetech.ca/> 
> 
>  
> 
> The css is located at: http://rebootnb.dimetech.ca/stylereboot.css
> 
>  
> 
> Any help is much appreciated.
> 
>  
> 
> Matt
> 
>  
> 
>  
> 
>  
> 
>  
> 





More information about the thelist mailing list