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
gzip has compression levels 1-9, where 9 gives us maximum compression but at the slowest speed. The default compression level is 6 and is a good compromise between speed and compression ratio.
GZip Compression can be enabled directly through IIS. Now if we go back to IIS, we should see that the compression page has changed. At this point we need to make sure the dynamic compression checkbox is checked and we're good to go. Compression is enabled and our dynamic content will be Gzipped.
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.
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With