Jonathan
Jonathan

Reputation: 1981

Enabling gzip compression on Azure Websites

I have an ASP.NET application running on an azure website using the standard tier. I have been trying to get gzip compression working on it. I've modified my web.config file and added the following under system.webServer

<urlCompression doStaticCompression="true" doDynamicCompression="true"/>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
    <dynamicTypes>
        <add mimeType="text/*" enabled="true"/>
        <add mimeType="message/*" enabled="true"/>
        <add mimeType="application/javascript" enabled="true"/>
        <add mimeType="application/x-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="application/x-javascript" enabled="true"/>
        <add mimeType="*/*" enabled="false"/>
     </staticTypes>
</httpCompression>

This works when running locally with IIS express but does not work when deployed to azure. The response contains the following headers.

Accept-Ranges:bytes
Content-Length:5381
Content-Type:text/css
Date:Fri, 04 Sep 2015 20:44:01 GMT
ETag:"56386b2e88dad01:0"
Last-Modified:Wed, 19 Aug 2015 14:06:02 GMT
Server:Microsoft-IIS/8.0
X-Powered-By:ASP.NET

Upvotes: 6

Views: 4445

Answers (1)

Bruno Faria
Bruno Faria

Reputation: 5272

You are missing the <scheme> element

<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />

More info here:

https://www.iis.net/configreference/system.webserver/httpcompression/scheme

<urlCompression doStaticCompression="true" doDynamicCompression="true"/>
<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="application/x-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="application/x-javascript" enabled="true"/>
        <add mimeType="*/*" enabled="false"/>
     </staticTypes>
</httpCompression>

Upvotes: 5

Related Questions