Register | Login
Friday, July 04, 2008

Sections
  
About Us
  
Hosting Provided by Server Intellect
Partners
Downloads
  
 WWWCoder.com Resource Directory

IIS Compression in IIS6.0
10/18/2004 10:25:29 AM

Hold on to your hats folks. If you’re running IIS6.0, pay for bandwidth, and don’t have compression installed on your web server, either IIS Compression or a 3rd party, you are missing out!!

By Scott Forsyth

In the day of IIS5 and earlier the compression built into IIS had various issues and was really not worth implementing. Enabling compression would require you to a 3rd party solution like http://www.port80software.com or http://www.xcompress.com. This has all changed in IIS6! At http://www.orcsweb.com we've been running IIS6.0 compression on some servers for a number of months with few issues; just huge performance and bandwidth benefits. Expect upwards of 4 times the compression which directly translates to bandwidth savings. that pages load faster for the end user! We’ve had only one client that required that this feature be disabled; it was for a custom audio application that didn't work with compression. I'll mention at the end of this how to disable compression for an individual site.

Though, compression in IIS v6.0 is much better than it once was, it still lacks a nice interface to manage it. One of the issues still there today with compression in IIS is that there isn't a nice interface to manage it. It's not as straight forward as other features of IIS.

No need to worry though, I'll explain the ins and outs of proper implementation below. I set out to implement IIS Compression a number of months ago, but, I found it difficult due to the lack of available information on the subject. I did find one great post here: Click to see post I've since jumped into this subject in more depth and have two things to add to Brad Wilson's article. One, an iisreset is required as I'll mention below but also there is another setting that is required for compression to be more practical for dynamic compression. The other link worth bookmarking is: Open hyperlink here (I won't make any promises that this link will always work, Microsoft seems to change their links to documents all the time)

To make it easier I'll include everything needed to properly enable IIS Compression below even though I'll repeat what Brad Wilson said.

First, before anything else, backup the metabase. This is done by right-clicking on the server in the IIS snap-in and selecting All Tasks -> Backup/Restore Configuration. The rest is straight forward.

Create Compression Folder (optional)

The first thing I do is create a folder on the D drive where the static file compression will be cached. I call it ASPNetCompressTemp but you can call it anything you want or leave the default of “%windir%\IIS Temporary Compressed Files” if that works for you. The IUSR_{machinename} will need write permission to the folder. If you use custom anonymous users, make sure to assign the proper user. IIS will still work even if the permissions are wrong but the compression won't work properly. Once running, it's worth double checking Event Viewer to see if any errors are occurring that keep IIS Compression from working.

Enable Compression in IIS

  • From the IIS snap-in, right-click on the Web Sites node and click on Properties
  • Select the Service tab - Enable Compress application files
  • Enable Compress static files
  • Change Temporary Directory to the folder that you created above, or leave it at it's default
  • Set the max size of the temp folder to something that the hard drive can handle. i.e. 1000.
  • Save and close the Web Site Properties dialog

Note: The temporary compress directory is only used for static pages. Dynamic pages aren't saved to disk and are recreated every time so there is some CPU overhead used on every page request for dynamic content.

Create a Web Service Extension (WSE)

IIS6.0 is much more proactive than IIS5 in regards to security and introduces a new feature called Web Service Extensions. This is great but means an extra step.

  • In the IIS snap-in select Web Service Extensions
  • Create a new web service extension
  • Call it HTTP Compression
  • Point it to c:\windows\system32\inetsrv\gzip.dll
  • Check the Set status checkbox so that it is enabled (Allowed)

Enable Direct Metabase Edit (optional)

One of many large improvement with IIS 6 is that the metabase isn't in binary format anymore and can be edited directly using Notepad or any other tools that allows editing an XML file. Personally I prefer to enable Direct Metabase Edit so that I can edit it and the change takes affect immediately. If this isn't enabled, you will need to stop and start the web services for any changes to take affect. Of course, like editing the windows registry there is always the chance of something going wrong so be careful. Unlike the windows registry though, if you make a mistake and the metabase is saved and doesn't conform to the proper XML scheme, it won't take affect, so thanks to the IIS team it's quite difficult to completely mess up the metabase. To enable this, right-click on the server (top level) in the IIS snap-in. There is a single checkbox that needs to be checked. This part couldn't get easier.

Now for the metabase changes

Now we move away from the IIS snap-in GUI and have to get our hands dirty. (well, as dirty as they can get when dealing with computer software)

Here is where the IIS team either wanted to make things a bit difficult or they didn't get the changes done in time for the final release of IIS6. Actually it's the latter as I've heard rumor that they will be improving on the GUI over time.

Note: If you want to save yourself the hassle of understanding all of this, purchase ZipEnable from Port80 Software. Open hyperlink here. This is a tool that gives you full control down to the folder and file level and embeds itself into the IIS MMC snap-in, making things much easier. I haven't tried this out so I can't attest to it myself but Port80 Software is a company that Microsoft has recommended for years to use if you want HTTP Compression.

There are a couple ways to do this. One is to edit the metabase directly using Notepad and the other is using adsutil.vbs usually found in your C:\Inetpub\AdminScripts folder. I'll explain the direct edit method because I find it's easier to picture and understand what is happening then using a command-line tool.

  • Open the metabase located at C:\Windows\system32\inetsrv\metabase.xml in Notepad
  • Search for <IIsCompressionScheme
  • There should be two of them, one for deflate and one for gzip. Basically they are two means of compression that IIS handles.
  • First thing to do is add aspx, asmx, php and any other extension that you need to the list extensions in HcScriptFileExtensions. Make sure to follow the existing format carefully, an extra space will keep this from working correctly. Do this for both deflate and gzip.
  • Now for the other thing commonly missed. HcDynamicCompressionLevel has a default value of 0. Basically this means at if you did everything else right, the compression for dynamic contact is at the lowest level. The valid range for this is from 0 to 10. I had the opportunity of receiving an internal testing summary from Chris Adams from Microsoft regarding the compression level -vs- CPU usage which showed that the CPU needed for levels 0 - 9 is fairly low but for level 10 it hits the roof. Yet the compression for level 9 is nearly as good as level 10. I write all this to say that I recommend level 9 so make sure to change HcDynamicCompressionLevel to 9. Do this for both deflate and gzip.
  • Just one thing left. There are two settings that required the World Wide Web Publishing Service (WWW service) be reset. One was enabling compression and the other was HcDynamicCompressionLevel. Even with it's shortcomings I simply do an iisreset from the command prompt but you can reset the service whichever way you prefer.

That's it folks. I didn't promise it would be easy but hopefully I was straight forward enough in my steps to keep this from being too difficult.

I should mention it is possible to disable or enable compression at the site or sub-folder level. This time I'll be lazy and tell you the adsutil.vbs way to do this but it can be done directly using Notepad and editing the metabase directly if you prefer. From the command prompt enter the following two commands and be sure to replace site# with the siteID that you are changing:

cscript C:\Inetpub\AdminScripts\adsutil.vbs set w3svc/site#/root/DoStaticCompression False

cscript C:\Inetpub\AdminScripts\adsutil.vbs set w3svc/site#/root/DoDynamicCompression False

Scott Forsyth is Director of IT at ORCS Web, Inc. - a company that provides managed hosting services for clients who develop and deploy their applications on Microsoft Windows platforms.


Page Options:
format for printing  Format for Printer
email article  Email Page
add to your favorites   Add to Favorites
How would you rate the quality of this content?
Poor - - Excellent
Comments?
Overall Rating:
Comments Left:
Left on 5/30/2008 10:35:25 AM by Anonymous
Comments: You can also use YSlow/Firebug extensions in Firefox to verify compression.
Left on 1/9/2008 2:16:27 PM by Anonymous
Comments: Scott rocks!
Left on 12/14/2007 6:51:23 AM by Anonymous
Comments: bakwas
Left on 3/27/2007 1:13:34 AM by Anonymous
Comments: I'mm not able to do compression for dynamic files, can somebody help me in implementing compression for aspx and asp file
No ratings available.
Left on 11/17/2006 5:06:08 PM by Anonymous
Comments: We use IISxpress for IIS compression. It does extension, content type, URL and IP filtering. It shows live compression stats too which is kinda neat.
Left on 11/17/2006 5:03:54 PM by Anonymous
Comments:
Left on 9/9/2006 8:51:50 AM by Anonymous
Comments: Excellent.
But I didn't understand why create the WebService?
Left on 5/5/2006 11:27:14 AM by Anonymous
Comments: You're right on the issue with zip files. We run into the same issues here on the site. In order to deal with it we use Blowery's HTTP Compression module. It's the same one that DNN uses. This module allows you to bypass compression based on the mime types being sent to the web browser. Just exclude zips and everything works great.
No ratings available.
Left on 5/5/2006 11:18:53 AM by Anonymous
Comments: Great article. I tried using gzip on IIS6 and the effect is quite impressive, but unfotunatelly we had a problem  downloading zip files from our application. Zipfile is created by application (asp.net 1.1) using SharpZipLib. After downloading zipfile on users local machine windows xp and also winzip reported corrupted zip, 7-zip opens it. The same zipfile is ok if gzip on IIS is disabled.
Thax 4 an article, Regards  iztokv@gmail.com

No ratings available.
Left on 2/27/2006 4:22:31 PM by Anonymous
Comments: You can go to www.pipeboost.com and enter in your URL to see how it does with compression versus uncompressed. You can also install Fidder (http://www.fiddlertool.com/fiddler/) for IE and it will provide you with information on the page your visiting and compressed versus uncompressed.
No ratings available.
Left on 2/27/2006 4:01:22 PM by Anonymous
Comments: How Does one Monitor afterwards if Compression actually did something? Can one trace this somehow?
Left on 11/30/2005 8:11:15 AM by Anonymous
Comments: Comments from the following blog: devnotebook, located at: http://geekswithblogs.net/juang/archive/2005/11/30/61660.aspx
No ratings available.
Left on 11/28/2005 2:59:43 PM by Anonymous
Comments: Comments from the following blog: devnotebook, located at: http://geekswithblogs.net/juang/articles/clickonceCompression.aspx
No ratings available.
Left on 8/8/2005 12:41:41 AM by Anonymous
Comments: Even after following the instructions, my site is being shown as not compressed by port80software and pipeboost...
No ratings available.
Left on 7/16/2005 8:56:04 AM by Anonymous
Comments: Comments from the following blog: thingelstad.com, located at: http://www.thingelstad.com/DotText/archive/0001/01/01/HTTPCompression.aspx
No ratings available.
Left on 7/10/2005 8:31:17 AM by Anonymous
Comments: Afer doing this I still got

Encoding from server:
- not supplied - (windows-1252)

no compression from server. :(
pm@email.net.au
Left on 5/7/2005 9:47:36 AM by Anonymous
Comments: Comments from the following blog: thingelstad.com, located at: http://www.thingelstad.com/DotText/archive/2005/05/07/HTTPCompression.aspx
No ratings available.
Left on 4/17/2005 11:16:26 AM by Anonymous
Comments: this link has more analysis on performance improvement with compression in IIS
http://www.intel.com/cd/ids/developer/asmo-na/eng/208335.htm

Left on 4/1/2005 8:11:05 PM by Anonymous
Comments: thanks, this was a great help
Left on 3/6/2005 10:34:32 PM by Anonymous
Comments: you can download a sniff software to see whether your HTTP compression is working or not.
No ratings available.
Left on 2/28/2005 12:05:18 PM by Anonymous
Comments: straight and to the point

excellent
No ratings available.
Left on 1/27/2005 10:17:27 PM by Anonymous
Comments: To check and see if compression is working go to www.pipeboost.com
No ratings available.
Left on 1/27/2005 10:16:31 PM by Anonymous
Comments: If you're looking for a free compression add on for IIS that supports compression based on directory and mime type, check out httpcompress at http://www.blowery.org/code/HttpCompressionModule.html
No ratings available.
Left on 1/5/2005 7:00:46 PM by Anonymous
Comments: Is this feature work for https?
No ratings available.
Left on 12/21/2004 3:33:57 AM by Anonymous
Comments: Thanks. Very clear and easy to understand. As the previous user mentioned, how can we confirm the compression is working? Using YATT as Brad Wilson has suggested still shows raw html responses. port80software says its compressed (gzip) but still displays a 3-4x compression factor possible. Then again it shows the same for orcsweb as well.
No ratings available.
Left on 12/18/2004 1:04:49 AM by Anonymous
Comments: great info. thanks
Left on 11/18/2004 12:33:34 PM by Anonymous
Comments: How can I be sure that HTTP compression is enabled?

http://www.port80software.com/products/httpzip/ is still telling me that my site is NOT compressed!  http://holistic.com.mt/h/default.aspx.  My email evan@holistic.com.mt
No ratings available.
  

 Latest Articles
  

 Latest News
  

 

Spotlight
Syndication

 


 


Digg This
 


DotNetNuke Platinum Benefactor

  
 

 Terms Of Use | Privacy Statement
 Copyright 2008 - Santry Technology Solutions, Box 172, Girard, PA 16417, (814) 774-0970