How can I troubleshoot why my IIS7 site is not gzip compressing?

6,269

Solution 1

For basics:

Check the browser is actually sending the Accept-Encoding header and its not being stripped by firewalls.

Enable Failed Request Tracing on response 200 and Web Server Compression and see what it says when IIS7 tries to compress the response.

Solution 2

You're not using HTTP 1.0 in your testing are you? The noCompressionForHTTP10="False" will prevent that from working.

What I suggest is to start over again and get compression working with the defaults, then add back the parts until it breaks again. Here's a default on a fresh install:

 <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/x-javascript" 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>
Share:
6,269

Related videos on Youtube

Chris Canal
Author by

Chris Canal

Updated on September 17, 2022

Comments

  • Chris Canal
    Chris Canal over 1 year

    I've got a number of websites on a single IIS7 machine running W2K8.

    I'm using Fiddler to help me figure out if something is compressed or not. Nothing is.

    So, I've googled for a few things and tried some things out. I have the following ...

    C:\Windows\System32\inetsrv>appcmd set config -section:urlCompression /doDynamic
    Compression:true
    Applied configuration changes to section "system.webServer/urlCompression" for "
    MACHINE/WEBROOT/APPHOST" at configuration commit path "MACHINE/WEBROOT/APPHOST"
    
    C:\Windows\System32\inetsrv>appcmd list config -section:urlCompression
    <system.webServer>
      <urlCompression doDynamicCompression="true" />
    </system.webServer>
    
    C:\Windows\System32\inetsrv>appcmd list config -section:serverRuntime
    <system.webServer>
      <serverRuntime frequentHitThreshold="1" />
    </system.webServer>
    

    I've made sure that the urlCompression, httpCompression and serverRuntime sections are unlocked.

    I've also added the following to my web.config :-

    <system.webServer>
        <serverRuntime frequentHitThreshold="1" frequentHitTimePeriod="00:10:00" />
        <!-- NOTE: This requires the following section to be unlocked: appcmd set config -section:urlCompression /doDynamicCompression:true -->
        <urlCompression doDynamicCompression="true" dynamicCompressionBeforeCache="true" />
        <httpCompression noCompressionForHttp10="False" noCompressionForProxies="False">
            <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" dynamicCompressionLevel="4" staticCompressionLevel="9" />
            <dynamicTypes>
                <clear />
                <add mimeType="*/*" enabled="true" />
            </dynamicTypes>
            <staticTypes>
                <clear />
                <add mimeType="*/*" enabled="true" />
            </staticTypes>
        </httpCompression>
        <caching>
            <profiles>
                <add extension=".css" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="07:00:00" location="Any" />
                <add extension=".js" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="07:00:00" location="Any" />
                <add extension=".png" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="07:00:00" location="Any" />
                <add extension=".jpg" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="07:00:00" location="Any" />
                <add extension=".jpeg" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="07:00:00" location="Any" />
                <add extension=".gif" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="07:00:00" location="Any" />
                <add extension=".zip" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="07:00:00" location="Any" />
                <add extension=".htm" policy="CacheUntilChange" kernelCachePolicy="DontCache" duration="07:00:00" location="Any" />
            </profiles>
        </caching>
        <staticContent>
            <clientCache cacheControlMaxAge="31.00:00:00" cacheControlMode="UseMaxAge" />
        </staticContent>
    ....
    </system.webServer>
    

    So checking this, i'm not sure what i've done wrong ... ??? any suggestions? how can i debug this to see what's not getting read it right, etc?

    I've also been doing 'force-refresh' when I grab the website content, etc. Definately not getting server-compressed :(

    Please help!

    Update 1: Browser request does include an Accept-Encoding: gzip, deflate .

  • Chris Canal
    Chris Canal over 14 years
    Browser is definately sending the Accept-Encoding: gzip, deflate (for both options). Can you provide more infor for the failed request tracing, please?
  • Tornal
    Tornal over 14 years
    Read up on this <a href="learn.iis.net/page.aspx/467/…>. On Step 4 choose respone of 200 and on step 5 check "WWW Server" and "Compression" Checkbox. Then follow the analyse steps. Hopefully if applying compression fails it should point you in the direction of why.
  • Tornal
    Tornal over 14 years
    Yea, I screwed up the link but its in there
  • Chris Canal
    Chris Canal over 14 years
    How will the noCompressionForHTTP10="False" will prevent that from working? By setting that to false, you're telling it to compress for 1.0 .. ???