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   

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<March 2010>
SMTWTFS
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Comment Stats

DayTotal% of Total
Sunday 2056.8%
Monday 42514.1%
Tuesday 51917.2%
Wednesday 55518.4%
Thursday 58019.2%
Friday 54718.1%
Saturday 1886.2%
Total 3019100.0%

Hour1Total% of Total
12:00 AM 782.6%
1:00 AM 812.7%
2:00 AM 682.3%
3:00 AM 822.7%
4:00 AM 692.3%
5:00 AM 1264.2%
6:00 AM 1183.9%
7:00 AM 1816.0%
8:00 AM 1926.4%
9:00 AM 1585.2%
10:00 AM 1886.2%
11:00 AM 1936.4%
12:00 PM 2016.7%
1:00 PM 1846.1%
2:00 PM 1695.6%
3:00 PM 1354.5%
4:00 PM 1153.8%
5:00 PM 1073.5%
6:00 PM 1013.3%
7:00 PM 1073.5%
8:00 PM 923.0%
9:00 PM 882.9%
10:00 PM 913.0%
11:00 PM 953.1%
Total 3019100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 4.97159
Monday 4.80384
Tuesday 4.04477
Wednesday 7.39680
Thursday 6.26676
Friday 5.07466
Saturday 4.78177
Total 5.403019

Hour1 Entry MadeAvg.Total
12:00 AM 5.2937
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 3.8550
8:00 AM 3.72134
9:00 AM 6.06297
10:00 AM 5.63276
11:00 AM 4.22194
12:00 PM 6.16351
1:00 PM 3.09133
2:00 PM 4.89230
3:00 PM 7.64321
4:00 PM 4.00108
5:00 PM 6.07170
6:00 PM 4.64116
7:00 PM 8.95188
8:00 PM 8.63164
9:00 PM 5.00115
10:00 PM 6.31101
11:00 PM 4.5732
Total 5.403019

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


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles