0

对于“text/html” mimeType, GZIP 不能在80端口工作,尽管其余类型可以正常使用 GZIP。因此,我尝试将端口更改为其他端口,例如808 或其他任何端口,一切都变得正确。所有的 mimiTypes 都包括"text/html"做 GZIP 很好。


80 端口响应标头:

文本/html不能 gzip

Cache-Control:private
Content-Length:2469
Content-Type:text/html; charset=utf-8

text/css或任何其他类型都可以正常工作

Accept-Ranges:bytes
Content-Encoding:gzip
Content-Length:1550
Content-Type:text/css

808 端口响应标头:

所有类型都包括text/html 工作 GZIP 罚款:

Cache-Control:private
Content-Encoding:gzip //became work fine!
Content-Length:1452
Content-Type:text/html; charset=utf-8


Accept-Ranges:bytes
Content-Encoding:gzip // work fine like before
Content-Length:1550
Content-Type:text/css

1.环境:asp.net mvc 2.0 + iis7.5 + windows2008 R2。

2. IIS配置:打开动态内容和静态内容压缩,根站点(我是指IIS树中的根节点,抱歉我不知道怎么用英文称呼它)和目标站点

3.根站点:%systemroot%\System32\inetsrv\config\applicationHost\ applicationHost.config

    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" doDiskSpaceLimiting="false" minFileSizeForComp="0">
            <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
            <dynamicTypes>
                <add mimeType="text/*" enabled="true" />
                <add mimeType="application/x-javascript" enabled="true" />              
                <add mimeType="message/*" enabled="true" />
                <add mimeType="*/*" enabled="false" />
            </dynamicTypes>
            <staticTypes>
                <add mimeType="text/*" enabled="true" />
                <add mimeType="message/*" enabled="true" />
                <add mimeType="application/x-javascript" enabled="true" />
                <add mimeType="application/atom+xml" enabled="true" />
                <add mimeType="application/xaml+xml" enabled="true" />
                <add mimeType="*/*" enabled="false" />
            </staticTypes>
        </httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />

4.target站点的Web.config:同样在mimeType上面打开:

<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="application/json" enabled="true" />
    <add mimeType="application/json; q=0.5" enabled="true" />
    <add mimeType="application/json; charset=utf-8" enabled="true" />
    <add mimeType="application/json; q=0.5; charset=utf-8" enabled="true" />
    <add mimeType="*/*" enabled="false" />
  </dynamicTypes>
  <staticTypes>
    <add mimeType="text/*" enabled="true" />
    <add mimeType="message/*" enabled="true" />
    <add mimeType="application/x-javascript" enabled="true" />
    <add mimeType="application/atom+xml" enabled="true" />
    <add mimeType="application/xaml+xml" enabled="true" />
    <add mimeType="*/*" enabled="false" />
  </staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />

解决方案参考: asp.net mvc - 某些文件未压缩 http://www.iis.net/configreference/system.webserver/httpcompression

我怎样才能让 GZIP在 80 端口上为text/html工作?

4

0 回答 0