IIS 7.5 成功压缩但发送未压缩的版本作为响应

IIS 7.5 成功压缩但发送未压缩的版本作为响应

我已将 IIS 7.5 设置为对静态和动态内容使用 gzip 压缩。通过检查“IIS 临时压缩文件”文件夹,我已验证它确实正在压缩我在配置中定义的所有静态 MIME 类型。我还强制执行了失败请求跟踪,发现当请​​求(静态和动态)进入时,压缩正在成功执行,没有任何错误。

但是,IIS 返回给浏览器的响应是未压缩的。响应的大小相同,并且响应中没有“Content-Encoded: gzip”标头。

我的IIS配置:

    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" minFileSizeForComp="1" noCompressionForHttp10="false" noCompressionForProxies="false">
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
        <dynamicTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/json" enabled="true" />
            <add mimeType="application/json; charset=utf-8" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="application/x-javascript; charset=utf-8" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </dynamicTypes>
        <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/atom+xml" enabled="true" />
            <add mimeType="application/xaml+xml" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="application/x-javascript; charset=utf-8" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </staticTypes>
    </httpCompression>
    ...
    <urlCompression doStaticCompression="true" doDynamicCompression="true" />
    ...
    <serverRuntime frequentHitThreshold="1" />

示例请求(示例是动态的,但也同样处理静态类型):

    Accept:application/json, text/plain, */*
    Accept-Encoding:gzip, deflate
    Accept-Language:en-US,en;q=0.8
    Cache-Control:no-cache
    Connection:keep-alive
    Content-Length:0
    Cookie:ASP.NET_SessionId=...
    Host:...
    Origin:...
    Pragma:no-cache
    Referer:...
    User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36

示例响应:

    Cache-Control:private
    Content-Type:application/json; charset=utf-8
    Date:Tue, 29 Sep 2015 21:37:28 GMT
    Server:Microsoft-IIS/7.5
    Set-Cookie:.ASPXAUTH=...
    Transfer-Encoding:chunked
    Vary:Accept-Encoding
    X-AspNet-Version:4.0.30319
    X-AspNetMvc-Version:5.0
    X-Powered-By:ASP.NET

再次,我已经验证它已成功压缩,只是由于某种原因它没有在响应中发送压缩数据。

相关内容