Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to enable dynamic compression for the mime type application/json.

In applicationHost.config, I've made the following change:

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

I also tried unlocking the section with the following command:

appcmd unlock config /section:system.webserver/httpcompression

My web.config settings (same as applicationHost.config but with additional mimetype):

    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
        <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="application/atom+xml" enabled="true" />
            <add mimeType="application/xaml+xml" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </staticTypes>
        <dynamicTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="application/json" enabled="true" />
            <add mimeType="*/*" enabled="false" />
        </dynamicTypes>
    </httpCompression>

But the response is not being gzipped. I know the settings are correct as it works if I add the mimetype directly to applicationHost.config.

I've enabled Failed Request Tracing and no errors are produced.

share|improve this question
    
can u also try to add this under system.webServer node: <urlCompression doStaticCompression="true" doDynamicCompression="true" /> – tugberk Sep 11 '12 at 10:11
    
Unfortunately this made no difference. Also, in IIS 7.5 the default value for doDynamicCompression changed to true. – Ben Sep 11 '12 at 10:19
    
do your changes work in IIS Express? – tugberk Sep 11 '12 at 10:20
    
no, had to do the same thing (change applicationHost.config directly) – Ben Sep 11 '12 at 11:41
    
Did you ever resolve this issue? – Mario Sep 19 '12 at 17:58

Try also adding the mime type:

 <add mimeType="application/json; charset=utf-8" enabled="true" />
share|improve this answer

I'm having the same problem i.e. trying to get IIS (IIS 10 in my case) to gzip application/json but have discovered a workaround.

I've tried editing the ApplicationHost.config as well as the web.config with no luck. IIS simply ignores any compress settings for .json data. It will happily gzip any other mimetype you tell it compress though. So I changed the mimetype to text/json in web.config and now I have gzipped reponses:

<system.webServer>
  <staticContent>
    <remove fileExtension=".json" />
    <mimeMap fileExtension=".json" mimeType="text/json" />
  </staticContent>
  <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
    <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll"/>
    <dynamicTypes>
      <add mimeType="text/json" enabled="true"/>
    </dynamicTypes>
    <staticTypes>
      <add mimeType="text/json" enabled="true"/>
    </staticTypes>
  </httpCompression>
  <urlCompression doStaticCompression="true" doDynamicCompression="true"/>
</system.webServer>

Of course that may break other stuff - because now your response has Content-Type:text/json

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.