Making the most out of IIS compression - Part 2: Configuring IIS 6 compression

by Matt Perdeck 20. August 2011 09:46


In part 1 of this series, we saw how to use compression in IIS 7.

As of July 2011, IIS 7's predecessor, IIS 6, is still used by 72.4% of all the websites that use Microsoft-IIS (source). Additionally, using compression in IIS 6 is a lot harder than in IIS 7. Hence this article on IIS 6 compression.


Getting started

Unfortunately, configuring compression on IIS 6 is far from straight forward. It involves four steps:

  1. Switch on compression in the IIS Manager;
  2. Set permissions on the folder where compressed static files are cached;
  3. Update the metabase;
  4. Reset the IIS server.

Let's go through each step in turn.

Switch on compression in the IIS Manager

This consists of the folowing steps:

  1. Start IIS manager: Click on Start | Administrative Tools | Internet Information Services (IIS) Manager.
  2. Backup the metabase: Right-click on your server and then click on All Tasks | Backup/Restore Configuration. Click on the Create Backup button, enter a name for your backup, such as today's date, and click on OK. Finally, click on Close to get back to the IIS manager.
  3. Expand your server. Right-click on the Web Sites node and click on Properties | Service.

  4. If your server has enough spare CPU capacity, select Compress application files. Because there is no caching for dynamic files of compressed content, this will cause IIS to compress dynamic files on the fly for every request. As a result, dynamic file compression takes more CPU than compressing static files.
  5. Select Compress static files.
  6. The temporary directory is where compressed static files are cached. Leave the default for Temporary directory. Or enter a different directory, for example if your system drive is low on space. Make sure it sits on an uncompressed and unshared local NTFS volume.
  7. Set a maximum size for the temporary directory.
  8. Click on OK.

Set permissions on the folder where compressed static files are cached

For static compression to work, the IIS_WPG group or the identity of the application pool must have Full Control access to the folder where the compressed files are stored.

Unless you changed the folder in the previous step (in the Temporary directory field), it will be at C:\WINDOWS\IIS Temporary Compressed Files.

  1. Right-click on the folder and click on Properties | Security.
  2. Click on the Add button and add the IIS_WPG group, or the identity of the application pool.

  3. Allow Full Control to the identity you just added and click on OK.

IIS_WPG or IUSR_{machinename}?

There is conflicting advice on various websites as to whether you should give the IIS_WPG group or the IUSR_{machinename} account access to the folder where the compressed files are stored. However, my testing with a clean install of Windows Server 2003 and IIS 6 has shown that IIS 6 will only compress static files if the IIS_WPG group has Full Control access to that folder, irrespective of the level of access by IUSR_{machinename}.

Update the metabase

Next modify the metabase:

  1. Get IIS to allow you to edit the metabase. In IIS manager, right-click on your IIS server near the top of the tree on the left-hand side. Click on Properties, check Enable Direct Metabase Edit, and click on OK.
  2. You'll normally find the metabase in directory C:\Windows\system32\inetsrv, in file metabase.xml. Open that file with a text editor.
  3. Find the IIsCompressionScheme elements. There should be two of these: one for the deflate compression algorithm and one for gzip.
  4. In both the elements, extend the HcFileExtensions property with the extensions you need for static files used in your pages, such as .css and .js. You will wind up with something like the following:


    Keep in mind that there is no point in including image files here such as .gif, .jpg, and .png. These files are already compressed because of their native format.

  5. Also in both elements, extend the HcScriptFileExtensions property with the extensions you need for dynamic files, such as .aspx. You will wind up with something like the following:
  6. HcScriptFileExtensions="asp

  7. The compression level for dynamic files is set by the HcDynamicCompressionLevel property in both IIsCompressionScheme elements. By default, this is set to zero, which is too low. The higher you set this, the better the compression but the greater the CPU usage. You might want to test different compression levels to see which one gives you the best tradeoff between CPU usage and file size. Start testing at a low compression level and then increase this until CPU usage gets too high. The compression level can be between 0 and 10:


  8. The compression level for static files is set by the HcOnDemandCompLevel property in both IIsCompressionScheme elements. By default, this is set to 10, meaning maximum compression. Because compressed static files are cached (so that static files are not compressed for each request), this causes little CPU usage. As a result, you will want to stick with the default.
  9. Save the file.
  10. Disallow editing of the metabase. Right-click on your IIS server, click on Properties, uncheck Enable Direct Metabase Edit, and click on OK.

You'll find a full list of the available metabase properties here.

Instead of editing the metabase directly, you can run the adsutil.vbs utility from the command line to change the metabase. This allows you to write a script so you can quickly update a number of servers. For example, setting HcDoStaticCompression to true will enable static compression. This is done as follows:

  1. Open command prompt and change the directory to C:\Inetpub\AdminScripts
  2. Run the following command:

    cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true

More information about adsutil.vbs is here

Reset the IIS server

Finally, reset the server, so that it picks up your changes. Right-click on your IIS server and then click on All Tasks | Restart IIS.

Alternatively, open a command prompt and run:


Static files are not always served compressed

If a static file is requested and there is no compressed version of the file in the temporary directory where compressed static files are cached, IIS 6 will send the uncompressed version of the file. Only once that's done does it compress the file and store the compressed version in the temporary directory, ready to be served in response to a subsequent request for the file.


In this article we saw how enabling compression in IIS 6 involves four steps - switching on compression, setting permissions so compressed static files can be cached, updating the metabase and finally resetting the IIS 6 server.

If you enjoyed this series and want to know the full story on how to improve ASP.NET site performance, from database server to web server to browser, consider my book ASP.NET Site Performance Secrets.


Web Server

Add comment

  Country flag

  • Comment
  • Preview


Book: ASP.NET Site Performance Secrets

ASP.NET Site Performance Secrets

By Matt Perdeck

Details and Purchase

About Matt Perdeck

Matt Perdeck Presenting

Matt has written extensively on ways to improve web site performance.

more >>