3

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
Mark Henderson
  • 68,316
  • 31
  • 175
  • 255
user12145
  • 1,075
  • 6
  • 26
  • 47

2 Answers2

4

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.

Mark Henderson
  • 68,316
  • 31
  • 175
  • 255
1

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.

monkee
  • 329
  • 2
  • 4