IIS 7.5 Compression creates compressed file but returns the non-compressed one

感情迁移 提交于 2019-12-11 20:24:38

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/28833861/iis-7-5-compression-creates-compressed-file-but-returns-the-non-compressed-one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!