3

We have some rather lengthy AJAX calls in our app, some of which transmit over 100k of data across a rather slow encrypted network. I'd like to enable G-Zip compression on application/json to speed this up a bit. However, I'm having a tough time! First, note that the server definitely supports this. application/javascript and text/* compress just fine. The first thing I tried was adding the following to web.config in the <system.webServer> section:

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

This had no effect. I even enabled "*/*" on everything just to test.

Next, I dug up the all-powerful applicationHost.config file. This had:

<section name="httpCompression" allowDefinition="AppHostOnly" overrideModeDefault="Deny" />

Which I changed to:

<section name="httpCompression" allowDefinition="Everywhere" overrideModeDefault="Allow" />

Still no go. I did an iisreset just to make sure the new setting would take effect.

Lastly, I edited the actual <httpCompression> section in applicationHost.config and manually added in:

<add mimeType="application/json" enabled="true" />

Well, this actually worked! However, I feel it's a bit hacky to modify the applicationHost.config when I'd rather just enable this for a single web application. What am I doing wrong and why can't I override this in web.config? Thanks!

0

You must log in to answer this question.

Browse other questions tagged .