【问题标题】:GZip compression not working on Windows Server 2016GZip 压缩在 Windows Server 2016 上不起作用
【发布时间】:2020-02-26 13:58:41
【问题描述】:

我安装了动态 GZip 模块,并在 IIS 中设置了相关设置,但是当我测试我的图像时,我使用的每个站点都告诉我没有安装 GZip。

  • ASP.net v4.6
  • Windows 服务器 2016
  • IIS 10.0

请求头:

Host: [redacted]
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:70.0) Gecko/20100101 Firefox/70.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Cookie: [redacted]
Upgrade-Insecure-Requests: 1
If-Modified-Since: Mon, 16 Sep 2019 15:23:43 GMT
If-None-Match: "b5b591b9a26cd51:0"
Cache-Control: max-age=0
TE: Trailers 

响应头:

HTTP/2.0 200 OK
content-type: image/x-icon
last-modified: Wed, 06 Sep 2017 09:19:33 GMT
accept-ranges: bytes
etag: "87b86540f126d31:0"
server: Microsoft-IIS/10.0
x-powered-by: ASP.NET
date: Thu, 31 Oct 2019 00:45:49 GMT
content-length: 1150
X-Firefox-Spdy: h2

IIS 设置:

Web.config:

    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" dynamicCompressionDisableCpuUsage="90" dynamicCompressionEnableCpuUsage="0">
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
        <dynamicTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="image/jpeg" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </dynamicTypes>
        <dynamicTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="image/png" 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="application/x-javascript" enabled="true" />
            <add mimeType="image/jpeg" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </staticTypes>
        <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/javascript" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="image/png" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </staticTypes>
    </httpCompression>

GZip 测试:

【问题讨论】:

  • blogs.msdn.microsoft.com/amb/2016/05/23/… 了解如何使用 FRT 进行查看。
  • IIS 不会压缩文件,除非它加载得足够频繁。您可以使用 Fiddler 之类的工具来检查压缩是否有效,它会向您显示 image
  • FREB 帮助我确定了 web.config 中的一些设置存在问题。我清除了所有配置并通过 IIS 完成,GZIP 现在可以工作了。

标签: iis gzip iis-10


【解决方案1】:

FREB 帮助我确定了 web.config 中的一些设置存在问题。我清除了所有配置并通过 IIS 完成,现在 GZIP 正在工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-20
    • 2016-05-14
    • 2017-03-20
    • 2018-04-19
    • 2015-10-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多