Search code examples
azure-cloud-serviceshttp-compression

IIS: How to enable httpcompression on site level?


In the Azure cloud service, we have start up task to enable httpcompression at the server level.

%appcmd% set config -section:system.webServer/serverRuntime /frequentHitThreshold:"1"
%appcmd% set config -section:system.webServer/urlCompression /doDynamicCompression:"True"

%appcmd% set config -section:system.webServer/httpCompression /-"dynamicTypes.[mimeType='text/css']"
%appcmd% set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='text/css',enabled='True']"

Then in the web.config, we do this to enable httpcompression at site level:

<urlCompression doDynamicCompression="true" dynamicCompressionBeforeCache="true" doStaticCompression="true" />

This does not work. In IIS Manager, I can see the site level has httpcompression enabled, but the response is not compressed.

However, if I set everything to false in web.config, then manually enable the settings in IIS Manager, it then works!

Any thoughts why that happens? This needs to be automated, so even though manually setting it works, it isn't a solution for me.

Thanks!!


Solution

  • Forgot to respond back with my finding - turns out I needed to remove the httpCompression and urlCompression settings in web.config , then everything just worked. Feels like an IIS bug.