About the author

Steven HarmanSteven Harman is a passionate developer who believes that writing great software isn't just a job, its a craft.

ASP.NET MVP

For recent posts and more about me, scroll to the bottom.

Subscribe

  • Subscribe to my feed. via RSS
  • Subscribe via email via email

Jobs

Badges

  • Subtext Project
  • Support Subtext
  • HiddenNetwork.com Banner

I'm all Zipped Up

Jeff Coding Horror Atwood recently posted an interesting and enlightening article about how he is reducing his site’s bandwidth usage.

As Jeff hints, these changes were prompted by the high bandwidth demands of his recent Why Can’t Programmers... Program? post (a.k.a. - The FizzBuzz Test). At it’s peak that post kicked his bandwidth usage up to 9GB in a single day.

In looking at his pretty bandwidth usage graph I also noticed his typical daily bandwidth is around 2.5GB. Now, I’m not nearly as popular a blogger as Mr. Horror, so I don’t expect that my daily bandwidth usage is even in the same ballpark. But that doesn’t mean that my readers shouldn’t benefit from a snappier page-load time, does it? Besides, there is nothing wrong with being a good net-izen and saving a little bandwidth where we can, is there?

Turn on IIS Compression

So I decided to enable HTTP Compression on my server.

I did a little Googling and found a great step-by-step guide from Scott Forsyth explaining how to turn on HTTP (GZip) compression on for IIS 6.0. The only addition I have is a snippet of my MetaBase.xml file that shows the file extensions you’ll probably want to enable compression for (my additions are in bold):

<IIsCompressionScheme 
    Location="/LM/W3SVC/Filters/Compression/deflate"
    HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
    HcCreateFlags="0"
    HcDoDynamicCompression="TRUE"
    HcDoOnDemandCompression="TRUE"
    HcDoStaticCompression="FALSE"
    HcDynamicCompressionLevel="9"
    HcFileExtensions="htm
        html
        txt
        xml
        css
        js
        rdf"
    HcOnDemandCompLevel="10"
    HcPriority="1"
    HcScriptFileExtensions="asp
        dll
        exe
        aspx
        asmx"
>
</IIsCompressionScheme>
<IIsCompressionScheme 
    Location="/LM/W3SVC/Filters/Compression/gzip"
    HcCompressionDll="%windir%\system32\inetsrv\gzip.dll"
    HcCreateFlags="1"
    HcDoDynamicCompression="TRUE"
    HcDoOnDemandCompression="TRUE"
    HcDoStaticCompression="TRUE"
    HcDynamicCompressionLevel="9"
    HcFileExtensions="htm
        html
        txt
        xml
        css
        js
        rdf"
    HcOnDemandCompLevel="10"
    HcPriority="1"
    HcScriptFileExtensions="asp
        dll
        exe
        aspx
        asmx"
>

Is it any faster?

I did some before-and-after testing of various pages on my site and I’ve already seen a 75% savings in file size with compression enabled. Granted, that number is only measuring the text files (.aspx, .css, .js, etc...) that are sent down to the browser.

I may look into Jeff’s suggstion of outsourcing my image hosting at some point down the road... and I’m almost certainly going to take another look at FeedBurner for serving my RSS Feeds.

Is compression enabled on your site?

I also stumbled across this cool online utility from port80software that allows you to quickly and easily determine if your web server has HTTP Compression enabled.

Let me know if you see any odd behavior on my site - like images, .zip archives, etc... not downloading properly or being corrupted by the download process.

Happy zipping to you!

Tags:

What others are saying.

# I'm all Zipped Up
Gravatar DotNetKicks.com
Mar 07, 2007
You've been kicked (a good thing) - Trackback from DotNetKicks.com
# re: I'm all Zipped Up
Gravatar Mads Kristensen
Mar 07, 2007
Great article. The approach you take in the post demands that you have full access to the IIS. Most websites are hosted by third-party centers where there is no access to the IIS. In those cases you can do HTTP compression natively in ASP.NET 2.0. See how here.
# re: I'm all Zipped Up
Gravatar Steve Harman
Mar 07, 2007
@Mads: I agree that you do need access to the IIS server itself, which is not likely to be available for those running on a hosted server like you mention.

The ASP.NET 2.0 solution that you propose is a start, but it is far from complete. It doesn't handle compressing other file types that are used by a page (CSS, JavaScript, XML, etc...).

That being said, your article should serve as a good starting point for those looking to build a more robust compression module for ASP.NET 2.0.

Thanks for the feedback!
# re: I'm all Zipped Up
Gravatar Ishwar Singh
Oct 16, 2007
Hi ,
even i enabled the http compression in our site and we are recieving this problem file being corrupted(.zip files).

do you have any idea

thnks.
Comments have been closed on this topic.