Beware the default nginx config - old IE6 hates gzip

I had some issues with an application deployed to EngineYard recently, using their standard nginx config with a few mongrels behind it. The issue was only happening with IE6, and only happening intermittently. And of course, I could not reproduce it locally. After some fun-filled research and gotomeeting’s with folks who saw the issue, it turned out it was only happening in pre service pack 2 versions of IE6.

I was aware that there were known issues with older versions of IE and gzipping, so I took a look at the nginx config. This was a config that EngineYard installed standard, out of the box. The gzip section looked like this:

gzip            on;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_buffers 16 8k;
gzip_types      text/plain text/html text/css .... # etc

The issue here is that you are serving gzipp’ed content to every browser that claims they can take it, even crappy browsers that totally suck and will bark every 5th request on some gzipp’ed css or js.

Beware: these settings are what you find commonly from different Rails sites with ngninx config templates.

The solution is simple - add the following line to your nginx config:

gzip_disable "MSIE [1-6]\.";

Yes, this will exclude versions of IE6 that can safely take gzip, but I didn’t have the time or inclination to find the user agent regex fu to only exclude IE6 SP1 and older. Comments appreciated if you refine it to only exclude IE6 SP1 and lower.

Update Thanks to Jauder in the comments for the better regex to only get the versions we really want:

gzip_disable "MSIE [1-6]\.(?!.*SV1)";

Back to the front page