启用 GZIP 压缩错误:STATIC_COMPRESSION_NOT_SUCCESS
我正在尝试在 IIS 7.5 上启用 GZIP 压缩。
我认为所有设置都没有问题。
在 ApplicationHost.config 中,我有这个 http压缩部分:
<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>
和这个 url压缩部分:
<urlCompression dostaticcompression="true" />
这是失败的请求跟踪结果:
STATIC_COMPRESSION_NOT_SUCCESS
Reason="UNKNOWN_ERROR"
I'm trying to enable GZIP compression on IIS 7.5.
I think all the settings are okay.
In ApplicationHost.config I have this httpCompression section:
<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>
And this urlCompression section:
<urlCompression dostaticcompression="true" />
and Here is Failed Request Tracing result:
STATIC_COMPRESSION_NOT_SUCCESS
Reason="UNKNOWN_ERROR"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下配置对我有用。只需将 applicationHost.config 中的 httpCompression 部分替换为下面给出的内容,然后重新启动 IIS。就是这样!!!
配置完成后,我得到了以下标头响应,这表明数据是使用 gzip 压缩进行压缩的
。 上述配置适用于整个 IIS。如果您想为单个网站配置此选项,请在 applicationHost.config 中替换
为
,而不是替换 applicationHost.config 中的 httpCompression 部分,而是将其添加到您网站的 web.config 中的 system.webServer 标记下
。此外,请确保您已为您的数据指定正确的 MIME 类型。就我而言,它是 JSON 格式,所以我使用了以下配置
The below configurations worked for me. Just replace the httpCompression section in applicationHost.config with the given below and restart IIS. That's it!!!
After configuring this, I got the below Headers in response which indicates that data is compressed using gzip compression
The above configuration is for the entire IIS. If you want to configure this for a single Website then replace
with
in applicationHost.config and instead of replacing the httpCompression section in applicationHost.config, add it under system.webServer tag in web.config of your Website
Also, make sure that you have specified correct MIME type for your data. In my case it was in JSON, so I used below configurations
如果我查看 html5-boilerplate 项目的 web.config,他们使用此方法:
https://github.com/paulirish/html5-boilerplate-server-configs/blob/ master/web.config
也许是您指定的零值,或者您正在使用的目录路径。
另请参阅
If I look at web.config of the html5-boilerplate project they use this method:
https://github.com/paulirish/html5-boilerplate-server-configs/blob/master/web.config
Perhaps it's the zero value you have specified, or the directory path you are using.
See also
我建议检查应用程序池用户帐户(如果有)是否对目录“%SystemDrive%\inetpub\temp\IIS Temporary compressed Files”具有特定的完整权限
I suggest checking that the application pool user account, if you have any, has specific full rights on the directory
"%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"