kumar
kumar

Reputation: 9387

How to enable gzip compression of Angular 6 asp.net core 2.1 which is hosted in Azure App services

How do I enable gzip compression for Angular 6 asp .net core 2.1 which is hosted in Azure App services. Do I have to handle it in the code or is it a setting in Azure app services.

Upvotes: 0

Views: 1772

Answers (1)

Peter Pan
Peter Pan

Reputation: 24128

There are two ways to enable gzip compression for your app hosted in Azure App Services.

  1. Follow the IIS offical document HTTP Compression to configure the web.config file to enable it like the configuration sample as below.
<configuration>
    <system.webServer>
        <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
            <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
            <dynamicTypes>
                <add mimeType="text/*" enabled="true" />
                <add mimeType="message/*" enabled="true" />
                <add mimeType="application/javascript" enabled="true" />
                <add mimeType="*/*" enabled="false" />
            </dynamicTypes>
            <staticTypes>
                <add mimeType="text/*" enabled="true" />
                <add mimeType="message/*" enabled="true" />
                <add mimeType="application/javascript" enabled="true" />
                <add mimeType="*/*" enabled="false" />
            </staticTypes>
        </httpCompression>
    </system.webServer>
</configuration>
  1. Install a site extension named IIS.Compression Site Extension on Azure portal or Kudu Site extensions, as the figures below.

Fig 1. Move to Extension tab and click Add on Azure portal

enter image description here

Fig 2. Choose extension on Azure portal

enter image description here

Fig 3. Installation on Kudu Site extensions

enter image description here

Upvotes: 2

Related Questions