Panasonic Youth rob sanheim writes about software, business, ruby, music, stuff and things



Posted
7 February 2008 @ 10am

Tagged
Linux, Scalability

Discuss

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)";

4 Comments

Posted by
Wade
7 February 2008 @ 12pm

Good find.


Posted by
Erik
7 February 2008 @ 3pm

MSIE[1-6]\.~SV1\.

I believe that should target everything that is MSIE 1-6 and not SP2 (aka user-agent token SV1;) as per:

http://msdn2.microsoft.com/en-us/library/ms537503(VS.85).aspx#UATokenRef


Posted by
Jauder
20 February 2008 @ 3am

Erik,

That string does not work.

After an hour of pounding my head against the wall and the help of the freenode #perl channel, the following should work.

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


Posted by
Jauder Ho
17 March 2008 @ 10pm

I did a quick writeup on this. With the ability to exclude bad versions of IE, Vary usage can be turned on and gzip_http_version set to 1.1 instead of 1.0.

Here’s the link to the writeup.
http://tumblelog.jauderho.com/post/27655495

I’ve tested on my app and it works nicely behaving as expected.


Leave a Comment

autotest without the unit_diff [ANN] brain_buster 0.8.0 released