6

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
Jonathan
  • 1,923
  • 2
  • 16
  • 34
  • 1
    I think Gzip compression is enabled by default in Azure websites. so you shouldn't need any additional configs...http://stackoverflow.com/questions/14722464/gzip-compression-in-windows-azure-websites – Aram Sep 04 '15 at 23:20
  • It's not working by default for me. Also not working when I try to add it to the web.config. – Jonathan Sep 08 '15 at 20:45

1 Answers1

5

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>
Bruno Faria
  • 5,219
  • 3
  • 24
  • 27
  • I had this originally and ended up removing it while messing with the config. I just added it again but it does not work for me. There's still no gzipping going on. – Jonathan Sep 08 '15 at 20:44
  • how are you testing? I tested your original code and my code and both worked like it was supposed to. I had only to add the in order to make it work. – Bruno Faria Sep 08 '15 at 23:21
  • I'm looking at the headers in the response from the website. The files are also the original size without compression. I should mention that this code **does** work when running locally with IIS Express, just not on azure. – Jonathan Sep 09 '15 at 20:08
  • 1
    @Jonathan Did you get a resolution for this...it is driving me nuts that it doesn't work. – Darren Jun 05 '16 at 05:02
  • @Darren Sorry, I had to go live with this and had to eat that small performance hit. Never got enough time to figure this out. It was driving me nuts too until I couldn't spend more time on it. I might revisit this in the future though. Let me know if you're able to solve this, I'd really like to know what's up with it. – Jonathan Jun 07 '16 at 17:08
  • 1
    @Jonathan Today I decided to move the site from 'Australia-SE' to 'East-Asia' region. Now it works. – Darren Jun 08 '16 at 09:01