Go back to the main page

Proper mod_deflate configuration with IE 6


On Apache's page for mod_deflate they have a sample configuration titled "Compress everything except images". In this configuration it has an exception for Internet Explorer to only compress the mime type of text/html because IE 6 and below doesn't properly compress some other mime types ( javascript,css,xml,etc). However, I have found this configuration to be faulty by careful packet inspection using fiddler. I found by having the "!" in front of both no-gzip and gzip-only-text/html that everything ( js and css ) still was getting compressed in IE 6. By only having the "!" in front of the no-gzip text/html was compressed and not js or css. Internet Explorer 7 compressed everything as expected.

This configuration works at enabling compression of only text/html for Internet Explorer 6 ( IE 7 and 8 work fine with compression of most types of files ). Also, note that I don't have a browser match for Netscape and IE 5.5 and below because our web application doesn't allow them.

 SetOutputFilter DEFLATE
 #Highest 9 - Lowest 1
 DeflateCompressionLevel 9

 # IE 6 can only gzip text/html mime type.
 # Must have a ! in front of no-gzip but NOT in front of gzip-only-text/html
 BrowserMatch \bMSIE\s6 !no-gzip gzip-only-text/html

 SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$  no-gzip dont-vary
 SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary
 SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

  • Pushed on 10/18/2010 by Christian