mod_deflate is working but send wrong headers

TomShreds asked:

I’m using mod_deflate to server gzip content for js and css files.

Using curl I can see that it works and I can see the code but Chrome still thinks it’s gzip content and NOT stylesheets/javascript so it won’t render them.

Chrome says:
Resource interpreted as Stylesheet but transferred with MIME type application/x-gzip.

So I guess that’s apache sending wrong headers. But I don’t know how to fix it.

Anyone has an idea?

Server is running Ubuntu 12 64 bits, with apache2.


My answer:

Your links are wrong.

You’ve made links to file.css.gz, which just serves the gzipped file directly.

Instead, you should link to file.css. The web browser will figure out that the gzipped file is there (nginx) and serve it, or will compress it itself.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.