On Windows Azure, static compression is enabled by default. However, you would have to enable dynamic compression for your application.

This can be done by adding the following entry in the Application’s web.config @Configuration/System.WebServer

<urlCompression doDynamicCompression="true" doStaticCompression="true" />

This change is sufficient for web services and web applications. However, if your application returns a mime type that is not included in the default compression list, you would have to add these mime types using httpCompression.

Enabling HTTP Compression

  • Update the service definition file to contain this in the WebRole/WorkerRole tag
<Task commandLine="iisconfigchanges.cmd" executionContext="elevated" taskType="simple"></Task>
  • In your web-role, a cmd file (e.g. iisconfigchanges.cmd) with required commands to customize ApplicationHost.config configuration of IIS.
%windir%\system32\inetsrv\appcmd set config  -section:system.webServer/httpCompression /+"dynamicTypes.[mimeType='application/json; charset=utf-8',enabled='True']" /commit:apphost
  • If you need to compress any specific files other than mentioned above, find out the MIME types per your requirement and add similar commands to the file. Just make sure using Fiddler that you type the exact mime type returned by your application.
At the end of it, your application would start compressing the data returned by your application. Do test this using Fiddler or any other network monitoring tool.

Further Reading


Share your thoughts

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s