如何解决为什么我的 IIS7 站点没有进行 gzip 压缩?

Pur*_*ome 5 compression iis-7 gzip deflate

我在一台运行 W2K8 的 IIS7 机器上有许多网站。

我正在使用Fiddler来帮助我确定某些内容是否被压缩。没有什么是。

所以,我在谷歌上搜索了一些东西并尝试了一些东西。我有以下...

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>
Run Code Online (Sandbox Code Playgroud)

我已确保 urlCompression、httpCompression 和 serverRuntime 部分已解锁。

我还在我的 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>
Run Code Online (Sandbox Code Playgroud)

所以检查这个,我不确定我做错了什么......???有什么建议?我如何调试它以查看哪些内容没有正确阅读等?

当我抓取网站内容等时,我也一直在做“强制刷新”。绝对不会被服务器压缩:(

请帮忙!

更新 1:浏览器请求确实包含Accept-Encoding: gzip, deflate

小智 3

对于基础知识:

检查浏览器是否确实发送了 Accept-Encoding 标头,并且它没有被防火墙剥离。

对响应 200 和 Web 服务器压缩启用失败请求跟踪,并查看 IIS7 尝试压缩响应时显示的内容。