Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gzip compression in Windows Azure Websites

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?

like image 461
RonZ Avatar asked Feb 06 '13 05:02

RonZ


People also ask

How do i compress content in Azure Blob Storage?

Azure Blob Storage is capable of delivering the correct content-encoding: gzip headers, but you have to compress the data yourself and properly configure the headers. After being configured correctly the files can be downloaded directly or via CDN and properly leverage HTTP Compression with any web browser.

What is the maximum amount of content that Azure CDN can compress?

Azure CDN can be used to provide compression and performance improvements on top of blob storage but has an upper limit of 1MB for HTTP compression. There are a variety of scenarios where you may have content larger than the 1MB compression limit for Azure CDN.

What is Azure Storage and how do I use it?

Azure storage is an excellent option for storing assets for your web application (or even your entire static web application), but it is often preferable to have this data delivered to the browser using HTTP Compression to reduce file size and improve performance.


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.

like image 88
Peter Kellner Avatar answered Oct 19 '22 02:10

Peter Kellner


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:

  1. 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).

  2. 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.

  3. 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.

like image 3
BrainSlugs83 Avatar answered Oct 19 '22 02:10

BrainSlugs83