Enable Dynamic GZIP Compression for IIS Azure Web App

Discover how to boost the performance of your Azure Web App by leveraging the power of dynamic GZIP compression. Here's a step-by-step guide to ensure your application runs efficiently with optimal load times.

Accessing Kudu for Azure Web App Configuration#

To begin the process, access Kudu on Azure.

For an in-depth understanding, explore the official documentation.

A shortcut to your Kudu dashboard is by appending “scm” to your Azure Web App URL, forming the following link:

https://<yourapp>.scm.azurewebsites.net

After accessing Kudu:

Navigate directly to the CMD console for further actions.

Kudu Console Azure

Locating the Essential applicationhost.config File#

  • Access the root directory by clicking on the “Site root” icon.
  • From the listed directories, head over to the config folder.
  • Here, you'll find the crucial applicationhost.config file.

Alongside each file, you'll notice options for downloading, editing, or removing.

Kudu Azure App Config
Azure Kudu ApplicationHost Config

Adjust application host's config GZIP Compression Settings#

To enable dynamic compression:

  1. Click on the edit icon next to applicationhost.config.
  2. Within the <system.webServer> tag, ensure these compression settings are present:
  <urlCompression doStaticCompression="true" doDynamicCompression="true" />
  <httpCompression directory="C:\local\IIS Temporary Compressed Files" noCompressionForProxies="false">
      <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
      <dynamicTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/x-javascript" enabled="true" />
        <add mimeType="application/javascript" enabled="true" />
        <add mimeType="application/json" enabled="true" />
        <add mimeType="application/atom+xml" enabled="true" />
        <add mimeType="application/atom+xml;charset=utf-8" enabled="true" />
        <add mimeType="*/*" enabled="false" />
      </dynamicTypes>
      <staticTypes>
        <add mimeType="text/*" enabled="true" />
        <add mimeType="message/*" enabled="true" />
        <add mimeType="application/x-javascript" enabled="true" />
        <add mimeType="application/javascript" enabled="true" />
        <add mimeType="application/atom+xml" enabled="true" />
        <add mimeType="application/xaml+xml" enabled="true" />
        <add mimeType="application/json" enabled="true" />
        <add mimeType="image/svg+xml" enabled="true" />
        <add mimeType="*/*" enabled="false" />
      </staticTypes>
    </httpCompression>

Make certain your desired data types are included in either <dynamicTypes> or <staticTypes>.

After finalizing, don't forget to restart your app for the changes to take effect.

Troubleshooting: When HTTP Compression Doesn't work#

If the compression isn't functioning as expected, monitor key performance metrics such as CPU utilization and RAM usage. 

Excessive CPU usage might lead to automatic compression disabling.

Consider the dynamicCompressionDisableCpuUsage and dynamicCompressionEnableCpuUsage attributes, which dictate the upper and lower CPU utilization limits for enabling/disabling dynamic compression.

For a better attributes understanding, check the official description from Microsoft:

dynamicCompressionDisableCpuUsage

Optional uint attribute.

  • Specifies the percentage of CPU utilization at which dynamic compression will be disabled.
  • The default value is 90.

Note: This attribute acts as an upper CPU limit at which dynamic compression is turned off. When CPU utilization falls below the value specified in the dynamicCompressionEnableCpuUsage attribute, dynamic compression will be re-enabled.

dynamicCompressionEnableCpuUsage

Optional uint attribute.

  • Specifies the percentage of CPU utilization below which dynamic compression will be enabled.
  • The value must be between 0 and 100.
  • Average CPU utilization is calculated every 30 seconds.
  • The default value is 50.

Note: This attribute acts as a lower CPU limit below which dynamic compression is turned on. When CPU utilization rises above the value specified in the dynamicCompressionDisableCpuUsage attribute, dynamic compression will be disabled.

For a more comprehensive understanding of HTTP compression attributes, consider delving into the HTTP Compression article on the Microsift official site, which provides essential insights into the intricacies of dynamic GZIP compression in Azure Web Apps.

🚀Stay updated!#

Check our blog to stay informed about Azure developments, strategies, and tricks.

↑ Top â†‘