Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
share|improve this question
up vote 4 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 ( - 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.

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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