Hello,
Using Apache with mod_rewrite, when I load a .css or .js file and view the HTTP headers, the Content-type is only set correctly the first time I load it - subsequent refreshes are missing Content-type altogether and it's creating some problems for me. Specifically, gzip is not compressing these files.
I can get around this by appending a random query string value to the end of each filename, eg. http://www.site.com/script.js?12345
However, I don't want to have to do that, since caching is good and all I want is for the Content-type to be present. I've tried using a RewriteRule to force the type but still didn't solve the problem. Any ideas?
Thanks, Brian
More Details:
HTTP headers WITHOUT random query string value:
http://localhost/script.js
GET /script.js HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://localhost/
Cookie: PHPSESSID=ke3p35v5qbus24che765p9jni5;
If-Modified-Since: Thu, 29 Apr 2010 15:49:56 GMT
If-None-Match: "3440e9-119ed-485621404f100"
Cache-Control: max-age=0
HTTP/1.1 304 Not Modified
Date: Thu, 29 Apr 2010 20:19:44 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 PHP/5.3.1
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Etag: "3440e9-119ed-485621404f100"
Vary: Accept-Encoding
X-Pad: avoid browser bug
HTTP headers WITH random query string value:
http://localhost/script.js?c947344de8278053f6edbb4365550b25
GET /script.js?c947344de8278053f6edbb4365550b25 HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3
Accept: */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://localhost/
Cookie: PHPSESSID=ke3p35v5qbus24che765p9jni5;
HTTP/1.1 200 OK
Date: Thu, 29 Apr 2010 20:14:40 GMT
Server: Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/0.9.8l DAV/2 PHP/5.3.1
Last-Modified: Thu, 29 Apr 2010 15:49:56 GMT
Etag: "3440e9-119ed-485621404f100"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 24605
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: application/javascript