Configuring GZip Http Compression seems to be very easy work on IIS7 but I definitely meet a lot of problems. Finally I make it work and I would like to share my experience here. Hope it will be helpful to solve your problems.
1. Configure in web.config never works.
I added following settings on web.config

<system.webServer>
  <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
    <dynamicTypes>
      <add mimeType="text/*" enabled="true"/>
      <add mimeType="message/*" enabled="true"/>
      <add mimeType="application/*" enabled="true"/>
      <add mimeType="*/*" enabled="false"/>
    </dynamicTypes>
    <staticTypes>
      <add mimeType="text/*" enabled="true"/>
      <add mimeType="message/*" enabled="true"/>
      <add mimeType="application/javascript" enabled="true"/>
      <add mimeType="*/*" enabled="false"/>
    </staticTypes>
  </httpCompression>
  <urlCompression doStaticCompression="true" doDynamicCompression="true"/>
</system.webServer>

But it doesn’t seems to be work. Finally I find there is a setting in %WINDIR%\System32\inetsrv\config\appliactionHost.config

<section name="httpCompression" allowDefinition="AppHostOnly" overrideModeDefault="Deny" />

It indicated that only the changes in applicationHost.config can take effect. You need to change it to below to make your settings in web.config work.

<section name="httpCompression" overrideModeDefault="Allow" />

2. applicationHost.Config doesn’t work.

It was weird adding the httpCompression setting on the applicationHost.config still cannot make the IIS GZip my response.

It takes me long time to investigate. Finally, I found my IIS is running on 64bit version, and the applicationHost.config for 64bit IIS is located at %WINDIR%\SysWOW64\inetsrv\Config!

3. How to trace the IIS compression issue

To enable the IIS tracing, you need to

  1. Go to IIS Manager
  2. Select your website on connections panel
  3. On Action panel, click Failed Request Tracing
  4. Check Enable check box on the Edit Web Site Failed Request Tracing Settings dialog
  5. On Home panel, double-click Failed Request Tracing item
  6. On Action panel, click Add…
  7. Choose the right status code on the second step of the rule dialog. If your request is successful, but you want to see why the compress is not enabled, you need to enter 200.
  8. Click finish.

After successfully configured the Failed Request Tracing, you make a request, and go to folder: C:\inetpub\logs\FailedReqLogFiles

You can see under W3SVC8 folder, there are some xml files been generated, in the xml file, search for ‘Compression’, you will find the message with Error code like below. In my case, the error message is “NO_MATCHING_CONTENT_TYPE”.

<RenderingInfo Culture="zh-CN">
  <Opcode>DYNAMIC_COMPRESSION_SUCCESS<>
  <Keywords>
    <Keyword>Compression</Keyword>
  </Keywords>
</RenderingInfo>
   
© 2012 Xuanyi Li's Blog Suffusion theme by Sayontan Sinha