up vote 2 down vote favorite
1
share [g+] share [fb]

the following configuration in httpd.conf only gzip css and html, not javascript, any idea?

AddOutputFilterByType DEFLATE text/html text/plain text/javascript text/css
AddOutputFilterByType DEFLATE application/x-javascript
link|improve this question

72% accept rate
feedback

2 Answers

up vote 2 down vote accepted

That's most likely because the MIME type for Javascript is hotly contested.

Try adding application/javascript and text/x-js (as well as application/x-javascript)

That said, a more reliable way may be to filter based on the .js file extension. See the Request_URI directive for more info (http://httpd.apache.org/docs/2.0/mod/mod_deflate.html) - this may not work if you're using rewritten URLs that do not use the .js extension for JavaScript files.

If this doesn't work, then your distro of Linux may be using a completely different MIME type for JavaScript. Locate the TypesConfig directive in your config file, and have a look to see how it's defining JavaScript. Then add that MIME type in as well.

link|improve this answer
feedback

This is probably your best approach:

<IfModule mod_deflate.c>
      AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/x-javascript
      BrowserMatch ^Mozilla/4 gzip-only-text/html
      BrowserMatch ^Mozilla/4\.[0678] no-gzip
      BrowserMatch \bMSIE\s(7|8)  !no-gzip !gzip-only-text/html
      Header set Vary *
      DeflateCompressionLevel 1

Internet Explorer (certain versions) does not play well with hectic compression, so it's best to approach compression on a browser by browser basis. These settings are from a high volume website with lots of clients - and were the only settings we tried that worked 100% of the time.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.