I'm trying to override the httpCompression
element within Web.config for a site on an IIS 7.5 running Windows 7, but it does not seem to be read at all.
To check, I've introduced typeos within the element, but I can't even get a configuration error.
Here is an example of the httpCompression
element from Web.config
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<SCHEMEx name="deflate" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="false" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTUPES>
</staticTUPES>
</httpCompression>
When I introduce similar errors in other element (like ie modules
) I get a configuration error, so I know the config file is read.
I've unlocked the section in ApplicationHost.config:
appcmd unlock config /section:system.webserver/httpcompression
But that did not work, so I changed ApplicationHost.config manually so it now reads:
...
<section name="httpCompression" overrideModeDefault="Allow" />
...
What I'm really trying to accomplish is to set "deflate" as the only compression scheme for one of my sites.
For this to work, after unlocking the application.config file you have to set the specific configuration via command line as well..
1) Unlock the httpCompression part of the application.config:
C:\Windows\System32\inetsrv\appcmd.exe unlock config /section:system.webServer/httpCompression
2) Lets suppose you want to handle dynamic JSON requests (e.g. mimetype = application/json), you should use this command:
C:\Windows\System32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json',enabled='True']" /commit:apphost
3) If JSON requests is your case, you might also want to handle the charset=utf-8 variation, which for some reason is what IIS gives you back in most cases:
C:\Windows\System32\inetsrv\appcmd.exe set config -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost
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