Showing posts with label Enable Gzip Compression. Show all posts
Showing posts with label Enable Gzip Compression. Show all posts

Optimize IIS Performance using "Enable Gzip compression"

Enable Gzip compression :

Enable Gzip compression is one of the Feature to Optimize IIS and enhances the performance of sites and applications.
This feature allows user to use bandwidth more effectively and efficiently by using common compression mechanisms such as Gzip and Deflate.
It provides options to Configure HTTP Compression for both static and dynamic sites.
It is supported by Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista

How it works ?

Lets discussion how exactly the application works with out Compression and with Compression

Process with out Compression :

When you request a file like http://www.KnowledgeParlour.com/Default.html, your browser communicates to a web server as follows :

1. Browser sends request to get Default.html to Server.
2. Server checks if Default.html is available or not .
3. Server if Found Default.html then sends back the response code and the file.
4. Browser received the file which is around let 500KB, which is very slow . Then loads the file .

Process with Compression :

If the browser gets a .zip file (i.e. Default.html.zip) instead of normal Default.html , then it can save bandwidth and download time. Then The browser can download the zipped file, extract it, and then show it to user. Which is bit faster.
So using "Enable Gzip Compression" we can archieve the above process as follows :

1. Browser sends request to get Default.html to Server and informs to get the Compressed version of the response file.
2. Server checks if Default.html is available or not .
3. Server if Found Default.html then it Zip the file sends back the response code and the zipped File.
4. Browser received the Zipped file which is around 50KB , which is bit Faster and enhance the performance of application . Then it unzip the file and loads it .

Reason behind it :

When browser received the file from Server if it is smaller then it takes less time to download and process. so using Gzip Compression server makes the file let 500KB to 50KB which enhance the Performance and makes the application runs faster

How to configure compression ?

1. Open IIS Manager and navigate to the level you want to manage.
2. In Features View, double-click Compression.
3. Choose one or both of the following:
   a. Enable dynamic content compression to configure IIS to compress dynamic content.
   b. Enable static content compression to configure IIS to compress static content.
4. Click Apply in the Actions pane.

web.config Changes :

Once its applied , the following code has been updated in web.config file
<system.webServer> 
        <urlCompression doDynamicCompression="true" />
</system.webServer>