IIS 7.5压缩创建压缩文件但返回非压缩文件 [英] IIS 7.5 Compression creates compressed file but returns the non-compressed one
问题描述
我在IIS 7.5中设置压缩时遇到问题。在%SystemDrive%\inetpub\temp \IIS Temporary Compressed Files文件夹中,我的文件被gzip压缩,但浏览器会收到原始文件。即使用Ctrl + F5一次又一次刷新页面。此外,我在Chrome,FF和IE中测试了这个(没有Content-Encoding:gzip-header)。浏览器正在发送Accept-Encoding:gzip,deflate,sdch-header。有人可以给我一个提示吗?
这是我到目前为止所做的:
1)已更改appicationHost.config
< section name =httpCompressionallowDefinition =MachineToApplicationoverrideModeDefault =Allow/>
2)在cmd中执行以下命令
C:\ Windows \ System32 \inetsrv \ appcmd.exe unlock config /section:system.webServer/serverRuntime
3)将以下内容添加到web.config
< system.webServer>
< serverRuntime frequentHitThreshold =1frequentHitTimePeriod =10:00:00/>
< httpCompression>
< staticTypes>
< add mimeType =text / *enabled =true/>
< add mimeType =message / *enabled =true/>
< add mimeType =application / javascriptenabled =true/>
< add mimeType =application / x-javascriptenabled =true/>
< add mimeType =image / jpegenabled =true/>
< add mimeType =* / *enabled =false/>
< / staticTypes>
< dynamicTypes>
< add mimeType =text / *enabled =true/>
< add mimeType =message / *enabled =true/>
< add mimeType =application / javascriptenabled =true/>
< add mimeType =application / x-javascriptenabled =true/>
< add mimeType =image / jpegenabled =true/>
< add mimeType =* / *enabled =false/>
< / dynamicTypes>
< scheme name =gzipdll =%Windir%\system32 \inetsrv \ gzip.dlldynamicCompressionLevel =4/>
< / httpCompression>
< /system.webServer>
4)在Windows功能的性能特征中添加了静态和动态压缩功能-Installer(希望这样称为)
5)在服务器级启用静态和动态内容的压缩。并禁用min-file-size设置。
6)在网站级别启用静态和动态内容压缩。
编辑1:添加完整标题。
请求标题
接受:* / *
接受编码:gzip,deflate,sdch
接受语言:de-DE,de; q = 0.8,en-US; q = 0.6,en; q = 0.4
缓存控制:无缓存
连接:keep-alive
主机:web.web
Pragma:no-cache
Referer :http://web.web/
User-Agent:Mozilla / 5.0(Windows NT 6.1; WOW64)AppleWebKit / 537.36(KHTML,与Gecko一样)Chrome / 40.0.2214.115 Safari / 537.36
响应标题
接受-Ranges:bytes
内容长度:385105
内容类型:application / x-javascript
日期:星期二,03三月2015 14:09:48 GMT
ETag: 0535c4b155d01:0
最后修改时间:2015年3月3日星期二12:58:38 GMT
服务器:Microsoft-IIS / 7.5
变化:接受编码
X-Powered -By:ASP.NET
我找到了问题的根源。
我禁用了卡巴斯基反病毒软件,一切都按预期完成。
我不知道为什么会对这确实,但也许这有一天可以帮助某人。
编辑1
开服务器版本的卡巴斯基服务器一切正常。
I have trouble setting up the compressing in IIS 7.5. In the "%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" folder there are my files gzipped, but the browser recieves the original files. Even after refreshing the page again and again with Ctrl + F5. Also, I tested this in Chrome, FF and IE (no "Content-Encoding: gzip"-header). The browser is sending the "Accept-Encoding:gzip, deflate, sdch"-header. Can someone give me a hint?
Here is what i've done so far:
1) Changed the appicationHost.config
<section name="httpCompression" allowDefinition="MachineToApplication" overrideModeDefault="Allow" />
2) Executed the following command in cmd
C:\Windows\System32\inetsrv\appcmd.exe unlock config /section:system.webServer/serverRuntime
3) Added the following to the web.config
<system.webServer>
<serverRuntime frequentHitThreshold="1" frequentHitTimePeriod="10:00:00" />
<httpCompression>
<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>
<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>
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" dynamicCompressionLevel="4" />
</httpCompression>
</system.webServer>
4) Added the static- and dynamic-compression features in the Performance-Features in the Windows-Feature-Installer (hope this is called so)
5) Enabled the compression of static and dynamic content on the server-level. And disabled the "min-file-size"-setting.
6) Enabled the compression of static and dynamic content on the site-level.
Edit 1: Added the full headers.
Request Headers
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control:no-cache
Connection:keep-alive
Host:web.web
Pragma:no-cache
Referer:http://web.web/
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36
Response Headers
Accept-Ranges:bytes
Content-Length:385105
Content-Type:application/x-javascript
Date:Tue, 03 Mar 2015 14:09:48 GMT
ETag:"0535c4b155d01:0"
Last-Modified:Tue, 03 Mar 2015 12:58:38 GMT
Server:Microsoft-IIS/7.5
Vary:Accept-Encoding
X-Powered-By:ASP.NET
I found the source of my problem.
I disabled Kaspersky AntiVirus and everything worked exactly as expected.
I do not know why this has impact on this exactly, but maybe this helps someone someday.
Edit 1
On a server with the server-version of Kaspersky everything works as expected.
这篇关于IIS 7.5压缩创建压缩文件但返回非压缩文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!