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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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.

Method 2

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%inetpubtempIIS Temporary Compressed Files">
      <scheme name="gzip" dll="%windir%system32inetsrvgzip.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.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x