7

In ASP.NET MVC I have used the web.config to enable and configure the IIS7.5 gzip compression settings. But they compress level settings appear to have no effect at all:

<scheme name="gzip" dynamicCompressionLevel="9" staticCompressionLevel="9"/>

With compression level = 0 for both settings, my homepage is gzipped to 9,290 bytes (from 39,623)

With compression level = 9 for both settings, my homepage is gzipped to 9,290 bytes (from 39,623)

(using fiddler to check the zipped/uncompressed sizes)

There is no difference in the amount of compression - why is that? This occurs on my local development machine - Windows 7. I have not tried it on our Win 2008 web server yet.

Full compression settings in web.config:

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
  <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" dynamicCompressionLevel="10" staticCompressionLevel="10"/>
  <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="application/xml" 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="application/xml" enabled="true"/>
    <add mimeType="*/*" enabled="false"/>
  </staticTypes>
</httpCompression>
<urlCompression doStaticCompression="true" doDynamicCompression="true"/>

EDIT: apparently the highest level is 9. This page says it is 10 but must be incorrect http://www.iis.net/configreference/system.webserver/httpcompression/scheme. The problem is still the same when using level 9

dove
  • 20,469
  • 14
  • 82
  • 108
JK.
  • 21,477
  • 35
  • 135
  • 214

3 Answers3

2

Please double check you have dynamic compression installed

Next you might look at overriding some compression defaults dynamicCompressionDisableCpuUsage is set to 90% and compression will not kick in again until you go under dynamicCompressionEnableCpuUsage which defaults to 50%. I would suggest raising the latter.

Failed request tracing is also recommended in several places on SO for this kind of problem which might help you spot the issue.

There are some detailed answers to the following questions

How can I get gzip compression in IIS7 working?

Compression is not working

UPDATE:

The setting may be locked at the application level and so you should try running the following:

appcmd set config -section:urlCompression /doDynamicCompression:true

If it's still an issue it might be worth tweaking minFileSizeForComp whose default has increased with later IIS versions.

As per comment, also try just doing dynamic to start and leave off static while you're trying to nail this.

Community
  • 1
  • 1
dove
  • 20,469
  • 14
  • 82
  • 108
  • Sorry I didn't manage to get back to this question even though it has been bugging me. Dynamic compression is installed and working. But changing the compression level is not – JK. Oct 05 '12 at 00:53
  • @JK have you tried setting static compression to false and just do dynamic? I've updated answer with other suggestions – dove Oct 05 '12 at 06:36
1

If your home page is not dynamically generated, then the dynamicCompressionLevel would have no effect.

Since static compression is enabled by default, there was probably already a compressed version of your home page cached. You could try to simply modify your home page (e.g. just change one character). It should then recompress with the new setting.

It is possible that the default static compression is already at level 9. If you see no change, you can also try reducing the static level to 1 to see if there is a difference.

You may need to provide the DLL:

<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" />
Mark Adler
  • 101,978
  • 13
  • 118
  • 158
  • It appears dynamic compression module is not limited to dynamic content. In my own tests, it does compressed static content providing it matches its mime types list and is not already compressed. It should be understood as a "dynamic compression module", one that is triggered on each request. While the static module get triggered a bit like a background process working on files, and starts serving compressed output only once it has them in its cache. – Frédéric Sep 08 '15 at 09:00
0

Does your MVC pipeline include a compression filter ?

If yes, it will take precedence over IIS dynamic compression module. Settings on this module will have no effect on your MVC page since IIS dynamic compression module will not try to compress output that is already http compressed.

Frédéric
  • 9,364
  • 3
  • 62
  • 112