Aug202015

Enable GZIP Compression for Azure Web Apps

A recent addition to Azure Web Apps is the ability to customize the GZIP compression process. To enable compression for both static and dynamic content, add the following your your system.webServer section in your web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <urlCompression doStaticCompression="true" doDynamicCompression="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"/>
        <add enabled="true" mimeType="application/atom+xml;charset=utf-8"/>
      </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>
  </system.webServer>
</configuration>

This does work for ASP.NET 5 and MVC 6, as well, since this is configuring IIS, not the application stack.

References: