Search code examples
asp.netiishttp-compression

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


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

Solution

  • 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.