Designing and coding

Menu

How to enable HTTPCompression at IIS6

Last week, I was working on performance improvement of one of my projects. So I read several Articles on Internet and found that we can configure HTTPCompression on IIS. It compress the response sent to the browser and the size of the response get reduced dramatically i e major improvement in performance. So I wanted to share you all.

I’ll discuss it point wise.

1: Why do we need HTTP compression?

Nowadays, we are building Rich Internet Applications, which is increasing the size of Pages heavily. Means the more page size, more time it’ll take to load. But, IIS provides a feature to compress the responses and most common browsers support the HTTP Compression.

Means you can configure, HTTP compression at your web server, and browsers will understand it.

2: How much page size will be reduced.

Normally there are two algorithm supported. One is gzip and other one is deflate. I used Gzip in my website and found that the Page size was reduced by 60 to 70%.

3: When we don’t need compression.

If your page size are very less by default less than 60 to 70k. Then I think you don’t need this. Also if your users are having very high speed Internet then also you can ignore it. Because obviously the compression/decompression is a overhead if you are not gaining much.

4: How HTTPCompression works:

When a browser send a request to IIS, it also the send the information that what all kind of encoding supports. You can see the request header by many tools (One is Firebug that is available as a plugin for Firefox). You will be able to see following line in the request header.

Accept-Encoding: gzip,deflate

It says that this browser accepts gzip and deflate encoding

Now when IIS receives the request and find that that the requester can understand the given encoding. Based on the configuration, it encodes the response.

Now you can see the Response header. There it is mentioned, in what encoding is done on response as you can see it in header as

Content-Encoding: gzip

It means the response was encoded with gzip.

Here I am showing you all an example of Gmail.

Here I am showing the request header sent by the Firefox 3.5

It says it can accept encoding : gzip,deflate

Now let’s see the response header

As you can see, the response is sent is gzipped format

5: What will happen if Browser does not understand any encoding?

Actually when browser sends a request to the server it tells the server what all encoding it supports and that is available in Request Header. If it does not support, it may not send the Accept-Encoding tag.

Now when IIS receives the request and if it does not find any encoding mechanism supported by Requester, It does not apply any compression/encoding mechanism and the response is not encoded and sent it in normal format.

So you don’t need to worry about, it any browser does not understand gzip or deflate, then what will happen. IIS takes care, IT only encodes when it is supported by the requester.

6: How to configure HTTPCompression at IIS,

There are two types of Compression that can be configured.

First one: Static ( for static files like some css, javascript file etc.)

Other one: Dynamic (means for for dynamic generated page/response) .

There is no console available to configure to Configure HTTPCompression.

So there are two ways to configure HTTP compression at IIS.

First: Update the IIS metabase files directly.

Second: Use some commands to update it.

Here I’ll discuss the second one and will discuss the commands that can be used to configure it.

Here you need to do two things.

First: Configure the IIS for HTTPCompression

Second: Configure what all types/extension will be encoded

So for that you need to run the following commands at your web server:

Configure the IIS6 for HTTP Compression-

First Open command prompt and go to your IIS root folder, normally it would be “c:\inetpub\adminscripts\” then follow the below steps.

Post navigation

5 thoughts on “How to enable HTTPCompression at IIS6”

Hello Brij’s
Your articles really helpful to me.
Will u plz me help me. I am working on Reapeter. I create paging functionality for itand for that i create one web control library. So anyone when used it it provide paging functionality like gridview and the work for user is datasource binding.So now i want to provide Sorting functionality to it . i am trying but problem is repeater is in html format. so how i know cloumn.

There are several ways to do this.
First : You can have a hidden field. When user clicks on any header column, you update the column name in hiddden field from Javascript and make postback and at server side you can get the hiddenfield value sort it accordingly.

Another better way: Put link button in column of repeater.And on server click of linkbutton, you can implement Paging functionality.