[英]Why is gzip compression not working on IIS 8.5?
I am unable to get gzip compression working on IIS 8.5 on a Server 2012 R2 machine.我无法在 Server 2012 R2 机器上的 IIS 8.5 上使用 gzip 压缩。 I have done some research and followed the instructions found in these posts:
我做了一些研究,并按照这些帖子中的说明进行了操作:
Here is the relevant section of my config:这是我的配置的相关部分:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" staticCompressionIgnoreHitFrequency="true">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<!-- I have read that dynamic compression increases server CPU load.
<dynamicTypes>
<add mimeType="text/*" enabled="true"/>
<add mimeType="message/*" enabled="true"/>
<add mimeType="application/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>
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
Also, in IIS, I set compression to apply to anything larger than 256 bytes.此外,在 IIS 中,我将压缩设置为适用于大于 256 字节的任何内容。 And I have performed iisreset.
我已经执行了iisreset。
Nonetheless, I don't see the compression mentioned in my dev console in Chrome or IE and PageSpeed still tells me to compress stuff.尽管如此,我在 Chrome 或 IE 的开发控制台中没有看到提到的压缩,PageSpeed 仍然告诉我压缩内容。 What simple step have I missed?
我错过了什么简单的步骤?
It will be difficult to understand what is happening.Assuming that you have done all the IIS settings correct.很难理解发生了什么。假设您已正确完成所有 IIS 设置。
accept-encoding:gzip, deflate
.accept-encoding:gzip, deflate
。 many at times your proxy or load balancer can trim this header and this header may not reach the IIS server.So IIS will never compresseven if all the settings are done right. To verify what is happening for the request and why IIS did not compress the request,you can do the following.要验证请求发生了什么以及 IIS 未压缩请求的原因,您可以执行以下操作。
As mentioned in answers to one of the questions the OP links to, be sure to check for any anti-virus software running on the server.正如对 OP 链接到的问题之一的回答中所述,请务必检查服务器上运行的任何防病毒软件。 In my case it was ESET.
就我而言,它是 ESET。 None of the IIS compression settings had an effect until the relevant ESET settings were disabled.
在禁用相关 ESET 设置之前,所有 IIS 压缩设置均无效。
I'm leaving out details of the settings- I did what seemed like a pretty blanket disable and left it to IT to figure out which exact setting was most appropriate for compression to still work while retaining security.我省略了设置的详细信息 - 我做了一些看起来很全面的禁用,然后让 IT 找出哪种确切设置最适合在保持安全性的同时压缩仍然有效。
I had a similar issue and was caused by ESET with some strange behavior.我有一个类似的问题,是由 ESET 引起的,有一些奇怪的行为。 It worked on some machines but not on the one with eset, it took me some time to realize.
它适用于某些机器,但不适用于带有 eset 的机器,我花了一些时间才意识到。
What happened is that ESET caused chrome to downgrade http2 requests to http 1.1 and not compress them.发生的事情是 ESET 导致 chrome 将 http2 请求降级到 http 1.1 而没有压缩它们。 It can be seen if you open network and enable 'protocol' column.
如果您打开网络并启用“协议”列,则可以看到它。 After removing eset it worked even if I forced chrome to use http1.1 with '--disable-http2' flag
删除 eset 后,即使我强制 chrome 使用带有“--disable-http2”标志的 http1.1,它也能工作
Anyway if it still not working I would try to (in addition to the other answers):无论如何,如果它仍然不起作用,我会尝试(除了其他答案):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.