A standard feature of the Internet Information Server is HTTP compression. This module is available to optimize the performance of web applications by compressing HTTP responses that are sent to the client. The goal is to decrease the size of the responses to allow faster network transmission. Of course this has the side effect that the CPU usage increases on the server (and on the client). So we are trading CPU usage against bandwidth here. This means that HTTP compression doesnt always make your application perform better. The positive effects will be larger on slower networks and especially on WebApps running over the internet. If your server is already short on CPU power it might actually decrease the performance.
Note that all modern browsers support HTTP compression and the fallback system is pretty good. Browsers that support HTTP compression tell the server that they do by sending an HTTP Header with each request. This header called Accept-Encoding actually contains the supported compression types (usually GZIP and deflate). If this header is not found or doesnt contain the right type the server will send the data uncompressed.
More details on HTTP Compression can be found in this blog: http://weblogs.asp.net/owscott/archi...-how-much.aspx
Static vs Dynamic
Dynamic compression is the compression of content that is generated on the server when a request comes in. Examples of dynamic content are ASP scripts and DataFlex Web Service responses. Because the responses are generated when a request comes in the compression module cannot cache the response. This means that the data is compressed on the fly which results in extra CPU processing time for each request.
Installing HTTP Compression
Like the other standard parts of the Internet Information Server the dynamic compression module can be installed from the "Turn Windows features on or off" dialog that can be accessed from the control panel. The options "Dynamic Content Compression" and "Static Content Compression" can be found under "Internet Information Services > World Wide Web Services > Performance Features". The screenshot shows these two options.
After the features are enabled we should see the compression icon in the Internet Information Services (IIS) Manager as shown in the screenshot below. The compression can be enabled / disabled on all levels of IIS (Server, Website and Virtual Directory).
Enabling static compression
Enabling static compression is pretty straight forward. In this blog we will show how to do this for a specific virtual directory like the WebOrder_17_1 of the WebOrder sample. So in the IIS Manager we go to WebOrder_17_1 and double click the compression icon (as shown in the previous screenshot). There we check "Enable static content compression" and click Apply to save the changes.
Confirm that it works
After we have enabled static compression we will reload the page a couple of times using ctrl - f5. Note that reloading multiple times might be needed to let the compression module determine that a file is requested on a regular basis before it will compress it. Now we will see that the sizes displayed by FireBug go down dramatically. The screenshot below shows the same requests with static compression enabled. Note that df-min.js is compressed from 300KB to 60KB.
Enabling dynamic compression
Dynamic compression requires a bit more configuration. Not only does it need to be enabled, we also need to make sure that it recognizes the framework its AJAX Calls to the DataFlex WebService as dynamic content it can compress. This requires us to change some of the advanced settings of this module. These settings can be found in the IIS Manager in the configuration editor that we find at the server level. The screenshot below shows where to find it.
In the configuration editor we select the section "system.webServer/httpCompression" and then click at the prompt button after the option "dynamicTypes".
Dont forget to click Apply in the Configuration Editor after closing the Collection Editor. Now we can enable dynamic compression on the WebOrder_17_1 virtual directory by opening the compression settings after selecting this virtual directory.
Confirm that it works
To confirm that the dynamic compression works we will to look at the AJAX Calls using FireBug. To make this a bit easier we can filter the HTTP requests shown on the Net tab by clicking the XHR button (XHR stands for XmlHttpRequest). Almost every action in the WebOrder sample results in an AJAX Call. The screenshot below shows the calls for a couple of finds on the Order screen after dynamic compression is enabled.
As the sizes here depend on the state of the application we will look at the request itself to confirm that dynamic compression is enabled. If we expand one of the calls and look at the headers tab we will see that the response contains a header "Content-Encoding" with the value GZIP. This confirms that dynamic compression is now properly enabled.
Note that FireFox has sent the "Accept-Encoding" header to tell the server that it accepts compressed responses using the GZIP and deflate algoritms.