gpt4 book ai didi

iis - 启用 GZIP 压缩错误 : STATIC_COMPRESSION_NOT_SUCCESS

转载 作者:行者123 更新时间:2023-12-01 02:53:10 26 4
gpt4 key购买 nike

我正在尝试在 IIS 7.5 上启用 GZIP 压缩。

我认为所有设置都可以。

在 ApplicationHost.config 我有这个 httpCompression 部分:

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" minFileSizeForComp="0">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<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" />
</staticTypes>
</httpCompression>

这个 urlCompression 部分:
<urlCompression dostaticcompression="true" />

这是失败的请求跟踪结果:
  STATIC_COMPRESSION_NOT_SUCCESS     
Reason="UNKNOWN_ERROR"

最佳答案

以下配置对我有用。只需将 applicationHost.config 中的 httpCompression 部分替换为下面给出的内容并重新启动 IIS。就是这样!!!

  <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"
staticCompressionDisableCpuUsage="95" staticCompressionEnableCpuUsage="60"
dynamicCompressionDisableCpuUsage="95" dynamicCompressionEnableCpuUsage="50">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
<add mimeType="application/json" enabled="true" />
<add mimeType="application/json; charset=utf-8" enabled="true" />
</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="application/json" enabled="true" />
<add mimeType="application/json; charset=utf-8" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>

配置完之后,我得到了下面的响应头,表明数据是使用 gzip 压缩的
Cache-Control → no-cache
Content-Encoding → gzip
Content-Length → 4202
Content-Type → application/json; charset=utf-8
Date → Wed, 22 Jul 2015 07:40:17 GMT
Expires → -1
Pragma → no-cache
Vary → Accept-Encoding
X-Powered-By → ASP.NET

以上配置是针对整个IIS的。如果您想为单个网站配置此项,请替换
<section name="httpCompression" allowDefinition="AppHostOnly" overrideModeDefault="Deny" />


<section name="httpCompression" overrideModeDefault="Allow" />

在 applicationHost.config 中,而不是替换 applicationHost.config 中的 httpCompression 部分,将其添加到您网站的 web.config 中的 system.webServer 标记下

此外,请确保为数据指定了正确的 MIME 类型。就我而言,它是在 JSON 中,所以我使用了以下配置
<add mimeType="application/json" enabled="true" />
<add mimeType="application/json; charset=utf-8" enabled="true" />

关于iis - 启用 GZIP 压缩错误 : STATIC_COMPRESSION_NOT_SUCCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4091536/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com