I was making some changes to an Apache configuration this morning to ensure mod_deflate was compressing CSS and Javascript files and discovered I'd either documented the content-type for Javascript incorrectly, or the Apache version and Linux distro I used at the time served Javascript differently.
text/x-js vs application/javascript content-type
In the above linked post it's documented as being text/x-js. This worked for me at the time on that particular host. When I tried to configure this on a Debian host this morning it had no effect.
To find out what content-type was being served, I used the command line "lynx" web browser with the -head flag to display the headers like so (yes, that .local address is correct - I was testing this on my local development box which had the domain configured like that):
The output from this was:
Note the last line which shows the content type.
So using the application/javascript content-type I was then able to successfully have mod_deflate compress my Javascript files. I have also seen it in the past served as application/x-javascript
If you are having difficulty configuring mod_deflate and it doesn't seem to be compressing the files, then check the content-type using lynx as shown above and use that content type.
0 comments:
Post a Comment