IE6 gzip bug: solved using ISAPI_Rewrite

I’ve recently turned on gzip compression for all static pages on my web server running IIS6, and am now enjoying faster speeds and lower bandwidth.

However, in my investigations I came across a number of bugs in pre-SP2 IE6 (no surprises there) which means that gzipped CSS and Javascript files can be improperly cached and so intermittently mangled.

Not wanting to turn compression off just because of problems with this (thankfully declining) travesty of a browser, I hit on a way of bypassing compression for the affected browsers.

The solution uses ISAPI_Rewrite, which I already used on my server. Simply add the following lines to the global rules file (httpd.conf in your ISAPI_Rewrite installation directory):

RewriteEngine on
RewriteCond %{HTTP:User-Agent} MSIE\ [56]
RewriteCond %{HTTP:User-Agent} !SV1
RewriteCond %{REQUEST_URI} \.(css|js)$
RewriteHeader Accept-Encoding: .* $1

What this does is look at the User-Agent header of any incoming request. If it’s IE5 (just to be safe) or IE6, and the User-Agent doesn’t contain SV1 (which indicates IE6 SP2), and if the requested page is a .css or .js file, then we rewrite the Accept-Encoding header to a blank string (normally it would be gzip/deflate, which indicates that the browser can handle those compression methods).

The end result is that the affected browsers will not claim to handle compression, and so will get uncompressed files; everyone else will receive the benefits of compressed files.




Thanks, this solved our problem as well.

BTW, it does occur with all versions of IE6 including SP2 -- it just doesn't happen on all machines! This was a really strange one, but your suggestion to use ISAPI_Rewrite was a good one. I wrote my rule to exclude all versions of IE5/6.

21 January 2009, 02:34


I have similar problem in IIS6.0 after enabling the GZip compression. Please tell me how I will handle this in IIS6.0 by using ISAPI Rewrite.

I can't use any 3rd party tool here.



22 January 2010, 11:13
Seb Duggan


If you can't use any 3rd party tools, you won't be able to use the method outlined above.

However, I would suggest that you don't try to compress PDF files. You can set up the file types to be Gzipped by following these instructions:

...but if you can't use 3rd party tools, you may not be able to change the GZip setup either...

22 January 2010, 11:42

nice solution.. gonna test around and play with it..

14 March 2010, 16:48

legend - thanks solved my problems

19 October 2010, 14:56

Only problem is when intermediate proxy servers are involved.

Computer A (say IE7) requests file via Proxy P from server and gets compressed content.

Computer B (old IE6) requests file via Proxy P from server and also gets the compressed content and thus fails.

28 March 2011, 17:57

@bruceg: Use the "Vary: Accept-Encoding" header to counter that problem.

12 April 2011, 13:33