Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET compression

From an earlier post about trying to improve my sites performance I have been looking at HTTP compression. I have read about setting it up in IIS but it seems to be a global thing for all IIS application pools I may not be allowed to do this as there is another site running on it as well. I then saw some code to put in global.asax to achieve the same thing on a per website basis.

See Here http://www.stardeveloper.com/articles/display.html?article=2007110401&page=1]1

Is this as good as the setup in IIS? How dramatic is the effect? Any known issues?

like image 261
PeteT Avatar asked Sep 13 '25 13:09

PeteT


1 Answers

If you move forward with this, I'd suggest implementing a HttpModule versus global.asax. The HttpModule allows you to disable compression with a config change versus rebuilding and allows you to monkey with your compression Assembly separate from your web app.

Rich Crane has a pretty nice 2.0 module here: http://www.codeplex.com/httpcompression/ if you want to get up and running fast.

The blowery project Steven Rogers mentioned is a HttpModule as well.

Otherwise, writing your own is pretty straightforward. A HttpModule gives you the same events as global.asax - BeginRequest, EndRequest, and finer grained events like PostReleaseRequestState and PreSendRequestHeaders which you may need to iron out all the wrinkles.

As far as IIS compression verus HttpModule, IIS is definitely easier since you don't have to fuss with yet another Assembly. I've used both methods with business apps and both perform about equally under load testing. If IIS is available, I'd say use it.

Between 60 and 80% compression for HTML, JS, CSS, and XML files is common with gzip. Keep in mind a lot of your payload may be images and multimedia objects which are much harder to compress.

like image 125
Corbin March Avatar answered Sep 16 '25 07:09

Corbin March