Scott on Writing

Musings on technical writing...

HTTP Compression

The topic du jour for the ASP.NET developer blogging community seems to be HTTP compression.  HTTP compression involves the Web server compressing its HTTP response message using any one of a number of standard compression routines.  This compressed message is then transmitted to the requesting client where the client decompresses it and then does whatever it wanted to do with the data (display it in a browser, save it as a file, etc.).

When a Web browser makes a request to a Web server it can send along an Accept-Encoding header with a comma-delimited list of compression types accepted (the common ones being gzip and deflate).  The Web server, then, can then compress the response on the fly for these compression-aware Web browsers.  The cost of compression is a bit of extra processing time at the server and client to compress and decompress, respectively.  The benefit is in the decreased payload leaving the Web server, meaning the Web site's overall bandwidth is less and the data gets to the client sooner, which can be noticeably sooner for broadband-challenged visitors.  Compression of HTML documents can range based on the degree of compression used, and the compressibility of the data.  I've seen companies and individuals tout numbers ranging from 20% to 60%.  For example, James Avery noted a 45% savings by enabling compression on IIS.  (For a more in-depth discussion of HTTP compression, be sure to read: HTTP Compression Speeds Up the Web.)

So how does one go about enabling compression on their Web server?  There are third-party products that will fit the bill, PipeBoost and XCompress being two such products.  With Windows 2003 Server and IIS 6.0, IIS natively supports HTTP compression.  To learn how to configure IIS 6.0 for compression, be sure to read Scott Forsyth's IIS Compression in IIS 6.0 article, as well as Brad Wilson's article IIS 6 Compression and ASP.NET.

If you do not have access to your Web server, or you are not running IIS 6.0, you can still benefit from compression by using a custom ASP.NET HTTP module.  Ben Lowery has created a free HttpCompressionModule class that you can download and start using in your ASP.NET applications.  For example, Jeff Julian has integrated Ben's compression module with .Text, the blogging software used to run this blog and many others.  Specifically, Jeff's modification of .Text uses compression just on the RSS syndication feed (Rss.aspx), since this is typically the most requested file and is responsible for the majority of bandwidth used on a .Text Web site by far...

When visiting a Web site with compression enabled, the end user cannot determine if compression is used or not.  That's how it should behave, after all - everything should work just as it normally would. For more savvy end users, though, there is a means by which one can tell if the page they are viewing was sent over the wire as compressed data or not.  The simplest way is to inspect the HTTP response headers.  In Mozilla Firebird this is as easy as downloading Live HTTP Headers extension.  Look for a Content-Encoding header that has a value like gzip or deflate.  This would indicate that the content was encoded using a particular compression algorithm.  Another approach is to download a packet sniffer like Ethereal and capture the packets requested from the Web site.  When inspecting the payload you'll see the HTML content looks like a bunch of goobledygook - this is the compressed data.

posted on Monday, January 12, 2004 2:26 PM

Feedback

# re: HTTP Compression 1/12/2004 3:26 PM Scott Watermasysk

If you want to view the headers in IE, checkout: http://www.blunck.info/iehttpheaders.html

-Scott

# re: HTTP Compression 4/17/2005 9:31 AM puff

if you want to checkout more detailed analysis checout
http://www.intel.com/cd/ids/developer/asmo-na/eng/208335.htm

Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

Add To Your Reader

My Links

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<May 2008>
SMTWTFS
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Comment Stats

DayTotal% of Total
Sunday 1866.8%
Monday 37913.9%
Tuesday 45316.7%
Wednesday 50418.5%
Thursday 53519.7%
Friday 49418.2%
Saturday 1666.1%
Total 2717100.0%

Hour1Total% of Total
12:00 AM 652.4%
1:00 AM 682.5%
2:00 AM 622.3%
3:00 AM 742.7%
4:00 AM 572.1%
5:00 AM 1033.8%
6:00 AM 1084.0%
7:00 AM 1585.8%
8:00 AM 1716.3%
9:00 AM 1475.4%
10:00 AM 1716.3%
11:00 AM 1816.7%
12:00 PM 1886.9%
1:00 PM 1696.2%
2:00 PM 1605.9%
3:00 PM 1324.9%
4:00 PM 1073.9%
5:00 PM 923.4%
6:00 PM 913.3%
7:00 PM 963.5%
8:00 PM 833.1%
9:00 PM 782.9%
10:00 PM 792.9%
11:00 PM 772.8%
Total 2717100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.54144
Monday 5.22339
Tuesday 4.28419
Wednesday 7.67637
Thursday 6.90607
Friday 5.48411
Saturday 5.33160
Total 5.842717

Hour1 Entry MadeAvg.Total
12:00 AM 5.0035
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 7.0035
8:00 AM 5.35107
9:00 AM 6.32278
10:00 AM 6.47246
11:00 AM 4.41181
12:00 PM 6.88330
1:00 PM 3.00111
2:00 PM 5.41222
3:00 PM 8.64285
4:00 PM 4.0589
5:00 PM 5.92154
6:00 PM 4.52113
7:00 PM 9.67174
8:00 PM 9.80147
9:00 PM 5.05111
10:00 PM 5.4265
11:00 PM 4.5732
Total 5.842717

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles