Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 562
Jonathan Avatar asked Sep 04 '15 21:09

Jonathan


1 Answers

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>
like image 137
Bruno Faria Avatar answered Oct 17 '22 02:10

Bruno Faria