IIS7中的GZip压缩不工作,但内容编码标头设置为gzip [英] GZip compression in IIS7 not working, but content-encoding header is set to gzip
问题描述
我有启用静态和动态压缩的IIS 7.5。它似乎工作正常的动态文件,但对于静态的,它的行为不规律,通常发送一个http头Content-Encoding:gzip时,内容没有压缩。这导致浏览器尝试解压缩,抛出一个无效的魔法数字错误。这是我的配置:
I have IIS 7.5 with static and dynamic compression enabled. It seems to work fine for dynamic files, but for static ones it behaves erratically, often sending a http header "Content-Encoding: gzip" when the content is not compressed. This causes browsers to attempt to uncompress, throwing an invalid magic number error. Here's my configuration:
<httpCompression dynamicCompressionDisableCpuUsage="95" dynamicCompressionEnableCpuUsage="70" >
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="application/javascript" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="application/json" 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="*/*" enabled="false" />
</staticTypes>
一些http模块是解压缩管道内的内容,但没有一个看起来可疑。任何想法?
I thought some http module was uncompressing the content somewhere down the pipe, but none of them seem suspicious. Any ideas?
推荐答案
尝试在默认禁用的缓存之前启用动态压缩。
Try to enable dynamic compression before cache which is disabled by default.
<urlCompression dynamicCompressionBeforeCache="true" doDynamicCompression="true" doStaticCompression="true" />
这篇关于IIS7中的GZip压缩不工作,但内容编码标头设置为gzip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!