Web API Gzip not being applied
Is the WebAPI behind a Firewall, Web Proxy, Virus Protection Suite? As mentioned in Even Faster Web Sites: Performance Best Practices for Web Developers By Steve Souders This could be stripping out the headers.
Thanks to the 2 above solutions and other solutions elsewhere I figured a step by step explanation of how to get http compression working with Web API 2.2 might be beneficial as a few packages/namespaces have changed since the above posts.
1) Using nuget package manager console install the following;
Install-Package Microsoft.AspNet.WebApi.MessageHandlers.Compression
2) Inside WebApiConfig.cs add these usings;
using System.Net.Http.Extensions.Compression.Core.Compressors;
using Microsoft.AspNet.WebApi.Extensions.Compression.Server;
3) Inside WebApiConfig.cs add to the bottom of Register(HttpConfiguration config);
GlobalConfiguration.Configuration.MessageHandlers.Insert(0, new ServerCompressionHandler(new GZipCompressor(), new DeflateCompressor()));
4) Edit your web.config and inside system.webServer add;
<urlCompression doStaticCompression="true" doDynamicCompression="true" dynamicCompressionBeforeCache="true" />
<httpCompression>
<dynamicTypes>
<clear />
<add enabled="true" mimeType="text/*" />
<add enabled="true" mimeType="message/*" />
<add enabled="true" mimeType="application/x-javascript" />
<add enabled="true" mimeType="application/javascript" />
<add enabled="true" mimeType="application/json" />
<add enabled="false" mimeType="*/*" />
<add enabled="true" mimeType="application/atom+xml" />
</dynamicTypes>
<staticTypes>
<clear />
<add enabled="true" mimeType="text/*" />
<add enabled="true" mimeType="message/*" />
<add enabled="true" mimeType="application/javascript" />
<add enabled="true" mimeType="application/atom+xml" />
<add enabled="true" mimeType="application/xaml+xml" />
<add enabled="true" mimeType="application/json" />
<add enabled="false" mimeType="*/*" />
</staticTypes>
</httpCompression>
Worked first time on both local and an azure website so hopefully it works for you! Plus certainly no need to mess with applicationHost.config...