views:

34

answers:

1

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.

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

A: 

The answer depends on information you've not provided here, specifically where are you seeing these headers?

Unless it's from sniffing the network traffic between the browser and client, then you can't be sure if you are looking at a real request to the server or a request which has been satisfied from the cache. Indeed changing the URL as you describe is a very simple way to force a reload from the server rather than a load from the cache.

I don't think its as broken as you seem to. Fire up Wireshark and see for yourself - or just disable caching for these content types.

C.

symcbean
Confirmed that this was not broken in the first place. I had just employed gzip, and the uncompressed files had already been cached, so nothing was showing as compressed. Forcing a reload via URL would show correct results, but it wasn't until I did a more thorough cache cleanup that the issue was fully resolved. Thanks for the help.
Brian