1

I am trying to enable HttpCompression for Json files, but the system.WebServer/httpCompression is missing from the configuration editor options in IIS. I have the configuration applied in the Web.Config of my site, and it works fine in my development computer (Windows 10 - IIS 10), but when deployed to the test server it doesn't work.

These are our Web.config settings:

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" staticCompressionIgnoreHitFrequency="true" dynamicCompressionDisableCpuUsage="70" dynamicCompressionEnableCpuUsage="50">
      <remove name="gzip" />
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" dynamicCompressionLevel="4" />

      <dynamicTypes>
        <remove mimeType="text/*" />
        <remove mimeType="message/*" />
        <remove mimeType="application/javascript" />
        <remove mimeType="application/json" />
        <remove mimeType="image/svg+xml" />
        <remove mimeType="*/*" />

        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/javascript" enabled="true" />
        <add mimeType="application/json" enabled="true" />
        <add mimeType="image/svg+xml" enabled="true" />
        <add mimeType="*/*" enabled="false" />
      </dynamicTypes>
      <staticTypes>
        <remove mimeType="text/*" />
        <remove mimeType="message/*" />
        <remove mimeType="application/javascript" />
        <remove mimeType="application/xml" />
        <remove mimeType="image/svg+xml" />
        <remove mimeType="*/*" />

        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/javascript" enabled="true" />
        <add mimeType="application/xml" enabled="true" />        
        <add mimeType="image/svg+xml" enabled="true" />
        <add mimeType="*/*" enabled="false" />
      </staticTypes>
    </httpCompression>
    <urlCompression doStaticCompression="true" doDynamicCompression="true" />
    <serverRuntime frequentHitThreshold="1" frequentHitTimePeriod="00:00:05" />

I already ran the commands to unlock the corresponding sections:

%systemroot%\system32\inetsrv\APPCMD unlock config /section:httpCompression

%systemroot%\system32\inetsrv\APPCMD unlock config /section:serverRunTime

We have the Static and Dynamic Content Compression features are installed.

What are we missing? Why is the HttpCompression option missing in the Configuration Editor of the site? Why is not compressing our json files on the server?

Update We could figure out part of the issue. We were editing the apphost.config file with Notepad++ and because of the issue described in this post it seemed we were editing the right file, but we really weren't. It is an issue from the conflict of editing files with a 32 bits application. However it seems the issue no longer exist in Windows 10.

We edited the applicationHost.config file with Notepad and the HttpCompression option started to show in IIS Manager, but it is still not working.

Dzyann
  • 111
  • 1
  • 4

2 Answers2

2

The reason why you don't see it on the server 2012 R2 is the following line in ApplicationHost.config

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

on Windows 10 it looks like this:

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

on Server 2016 TP5:

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

AppHostOnly means, this can only be changed in ApplicationHost.config

This brings up a few questions:

Why did this change from IIS 8.5 to IIS 10, did they do something to now support httpCompression configuration on the site level, or was it just something they missed in previous IIS versions?

Would it work if we change it to allowDefinition="Everywhere" in IIS 8.5?

Can you put your httpCompression node inside a <location path=...> node in applicationhost.config?

Right now I don't have any answers, but at least you know why it doesn't work.

Peter Hahndorf
  • 13,763
  • 3
  • 37
  • 58
0

Find the ApplicationHost.config on IIS server files.

Change the section named httpCompression.

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

then open IIS server manager, open Compression, Check Enable Dynamic Content Compression Check Enable Static Content Compression

then open Configuration Editor on Manager panel. Navigate the dropdown menu.. System.Webserver -> HttpCompression -> staticCompressionIgnoreHitFrequency set to True.

System.web -> caching -> outputCache -> OmitVaryStar set to True.

Hope this works for IIS 8.5.

Best regards.

Asaprab
  • 101
  • 3
  • It has been a while, but incidentally in the next couple of months I will be probably working on something similar again, so I will try your suggestion and let oyu know. Thanks! – Dzyann Sep 26 '17 at 16:02