Last post Feb 28, 2013 09:23 AM by march11
Sep 06, 2010 01:06 PM|JonathanWood|LINK
I'm trying to improve the performance of my site using HTTP compression (GZIP or Default) but I'm having trouble finding the information I'm after.
My requirements are that I can't use IIS direct (my site uses shared hosting) and I don't want to use a 3rd party tool (my understanding is that it's not necessary). I'd prefer a web.config solution, if there is one.
I've been searching for a while. Most solutions I found are very old, some require direct access to IIS, and others require 3rd party tools. I found one that looked promising at http://www.stardeveloper.com/articles/display.html?article=2007110401&page=1,
but while it worked under Visual Studio it complains about app.Context.CurrentHandler being null when deployed on my site.
As I understand it, there's very little reason not to use compression but I'm having trouble finding current information.
Anyone else having better luck with this?
Sep 06, 2010 11:29 PM|mvark|LINK
Try this non-IIS way of implementing HTTP compression - http://pohee.com/it/http-compression-in-aspnet-20/
Sep 10, 2010 11:53 PM|JonathanWood|LINK
I finally found some code I was able to customize for my needs. It's small and it works. Here's what I ended up with:
protected void Application_BeginRequest(object sender, EventArgs e)
// Implement HTTP compression
HttpApplication app = (HttpApplication)sender;
// Retrieve accepted encodings
string encodings = app.Request.Headers.Get("Accept-Encoding");
if (encodings != null)
// Check the browser accepts deflate or gzip (deflate takes preference)
encodings = encodings.ToLower();
app.Response.Filter = new DeflateStream(app.Response.Filter, CompressionMode.Compress);
else if (encodings.Contains("gzip"))
app.Response.Filter = new GZipStream(app.Response.Filter, CompressionMode.Compress);
I just place this code in my Global.asax file and it seems to work great. Note that I made it favor deflate over gzip because I read deflate performs a bit better, although both forms are supported.
Sep 13, 2010 11:53 AM|JonathanWood|LINK
Well, then again, maybe not.
After testing with several browsers, the technique above seemed to be working. But then my CSS started messing up, and, finally, my pages just started producing garbage. Moreover, I found out that some versions of IE can't even correctly handle GZIP compression
Dangit. No wonder there is surprisingly few good articles on this topic.
Looks like this really isn't a valid option for me despite all the apparent advantages.
gzip deflate asp.net ie internet explorer
Feb 28, 2013 09:23 AM|march11|LINK
I realize this is an older post, but I was wondering if you had any further success with this after Microsoft released a fix and infact newer browsers.
It seems the issue you reported was a factor in IE6, as MS has moved well past that, have you been able to gain any performance increase?