Is it possible to Enable gzip compression on a simple Azure Website? If so how can it be done? Is there anything to take under consideration when applying gzip on Azure Websites?
-
check this post http://social.msdn.microsoft.com/Forums/hu-HU/windowsazuredevelopment/thread/a942a5bf-5f23-4b3f-8788-ace9efa5c7b6 – Dave Alperovich Feb 06 '13 at 06:02
-
Have you tried to enable compression by changing web.config? See http://stackoverflow.com/a/7171979/209727 – Davide Icardi Feb 09 '13 at 12:22
-
possible duplicate of [How to enable gzip HTTP compression on Windows Azure dynamic content](http://stackoverflow.com/questions/2775261/how-to-enable-gzip-http-compression-on-windows-azure-dynamic-content) – Brian Webster Feb 11 '13 at 04:10
-
It might be a duplicate, but as far as I know the OP might not be asking about dynamic content, but then, if he's only interested in gzipping static content, it may be related to http://stackoverflow.com/questions/7171434/iis-7-5-gzip-compression-at-shared-hosting – JayC Feb 11 '13 at 04:49
2 Answers
I just checked one of my azure web sites and it does look like gzip is working. I don't have anything special in my web.config so I think it must be enabled by default.

- 14,748
- 25
- 102
- 188
-
1How did you check that gzip is working? I have enabled gzip compression in IIS. However when I access an azure image, I am not gettting "Content-Encode:gzip" in the response headers though my request headers are "Accept-Encode: gzip, deflate". can u advise how to compress images? – mmssaann Jan 28 '14 at 12:04
-
take a look at the response headers and content size. https://dl.dropboxusercontent.com/u/613427/gzip.png – Peter Kellner Jan 28 '14 at 15:43
-
1yes I understand that you are getting Content-Encoding:gzip in response headers but I am not getting for my images though I have enabled compression in IIS. Would like to know what else I may need to do? – mmssaann Jan 29 '14 at 04:28
-
If you are not getting, I assume it is because iis is not configured properly. Beyond what is mentioned above for configuring IIS I don't really know what else to suggest. sorry. possibly post on http://forums.iis.net/ – Peter Kellner Feb 10 '14 at 17:14
-
3mmssaann, perhaps it is because images (JPG anyway) are mostly compressed already, and the overhead isn't worth the gains, if any. – Mar 30 '14 at 19:22
-
1Did you notice this post on [MSDN](http://blogs.msdn.com/b/windowsazure/archive/2014/01/28/more-to-explore-configuration-options-unlocked-in-windows-azure-web-sites.aspx) on how to enable http compression via .config? – DavideB Apr 03 '14 at 08:51
Per @DavideB's comment on the accepted answer, I found out that you can configure this for Azure / IIS via web.config. [ MSDN source ]
<configuration>
<system.webServer>
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%windir%\system32\inetsrv\gzip.dll"
doDynamicCompression="true" doStaticCompression="true"
staticCompressionLevel="7" dynamicCompressionLevel="7" />
<staticTypes>
<add mimeType="*/*" enabled="true" />
</staticTypes>
<dynamicTypes>
<add mimeType="*/*" enabled="true" />
</dynamicTypes>
</httpCompression>
</system.webServer>
</configuration>
Please note:
This will only work in Azure, or with IIS with the correct features installed (i.e. if you're using IISExpress, or vanilla IIS you're out of luck, see the article for the correct features, and configuration instructions for local testing).
The compression of Static and Dynamic resources are configured independently, and have separate default values; in practice you should configure your mimetypes and compression levels more carefully than I have.
Compression Level is between 0 and 10, where 0 == off, and 10 == maximum; Here, I've set mine to 7, with the reasoning that it's probably a good trade off between CPU usage and compression.

- 6,214
- 7
- 50
- 56