Setting Up Compression with IIS

One of the most commonly missed features of setting up a web server is configuring compression. All modern Browsers support both GZip and Deflate compression for content. All commercially viable web servers support GZip and Deflate compression types. IIS is no different. The reason many miss this feature is you have to configure it the way you need it to work in order for it to work. I am going to cover configuring compression in IIS 6 in this entry. I hope to follow up with some advice on IIS 7 soon.

Why Should You Compress Content

There are two primary reasons you should compress your web content, speed and bandwidth. Despite increasing the load on the CPU on the both the server and the client, compression makes a page load much faster. The reason is the content is transferred that much faster when compressed.

Saving bandwidth not only makes the site load much faster is also reduces your overall costs to operate the site. I know for my experience bandwidth is the highest cost to running any web site. Since I manage hundreds compressing content is a key factor in managing my bottom line. If you can reduce your bandwidth code by half that can be a tremendous addition to your bottom line. Think about a popular Blog, this could mean several thousand dollars a month they do not have to spend.

What Content Should I Compress

While there is so much to be gained by compressing the content sent form your web site, not all content should be compressed. A general rule of thumb is if it is text, like HTML or JavaScript then compress it. If it binary, like images or PDF files, then do not compress it. The binary files are generally going to be in a compressed format anyway.

How Do I Control What Gets Compressed

In IIS 6.0 you get the option of compressing Static and Dynamic content. You can designate that only static content gets compressed if you are worried about the compression of dynamic content adding too much stress to your server. But there should be few occasions where this is an issue. Static content will get cached to the file system compressed, so it will really speed up this content. Images do not get compressed, since the image formats are already in a compress format.

Compression Drawbacks

There are two drawbacks to using compression in IIS, performance and global setting. Anytime you add a routine that does processing on a resource in a web server there will be processing overhead. Compression is no different, since the compression algorithm must be executed. Fortunately this performance hit is more than made up for by the added speed going down the wire. Also IIS will intelligently cache compressed documents once they are compressed the first time to serve them faster on future request. Unfortunately this gets very complicated for dynamic applications like an ASP.NET application.

One of the things I don't like is using the built-in compression service in IIS 6.0 has to be an all or nothing setting. This means that all sites on the server are compressed or none use compression, this cannot be configured for each site.

One way around this is to integrate a custom httpModule into each ASP.NET site you want to implement compression. Blowery Compression seems to be the most popular for ASP.NET platforms. There are other solutions for other application frameworks and ISAPI dlls that may also be integrated.

How to Configure IIS 6.0 Compression

This is pretty easy, open the IIS Admin Interface. Bring up the properties dialog for the Web Sites Node, not an individual site. Select the Service tab. Check the Compress Application Files and Compress Static Files checkboxes. You can then specify the folder where the temporary files will be stored. I tend to put these on another drive in order to manage space on the server better.

How to See the Difference

Well there are several tools to see the difference, but the best one is your bottom line on bandwidth costs. If you have a high traffic site you will notice the difference in the actual bandwidth used immediately. This means less overhead to your wallet.

But honestly there are some great FREE tools to help you out. The first would be Fiddler, the indispensable add-in for Internet Explorer.

Conclusion

There is no reason you should not enable compression for your HTML, JavaScript and Cascading Stylesheets. Images, PDFs and other binary files do not need to be compressed if they are already in compress formats. Images and PDFs are already compressed. You can save a lot of bandwidth, which translates directly to the bottom line. It also makes your pages load much faster, adding to the overall perception of your site by end users. If you control your web server, configure compression, If you do not, then pressure your ISP or networking department to implement it immediately.

This covers compression in IIS 6, I have a follow up on how to setup compression in IIS 7 soon. I think I also should follow up with a more detailed explanation about how and why compression works on the web too.

Share This Article With Your Friends!

We use cookies to give you the best experience possible. By continuing, we'll assume you're cool with our cookie policy.

Install Love2Dev for quick, easy access from your homescreen or start menu.

Googles Ads Facebook Pixel Bing Pixel LinkedIn Pixel