Home > IIS Stories > Enabling HTTP Compression to save network cost in IIS7.x (#2/3)

Enabling HTTP Compression to save network cost in IIS7.x (#2/3)

IIS7.x includes IIS7 in Windows 2008 Server(or Windows Vista), & IIS7.5 in Windows 2008 R2(or Windows7). Once you provide Web Server role for your Windows Server, you just need to add ‘Static Content Compression, & ‘Dynamic Content Compression’ modules under ‘Performance Features’.  (They are not installed by default).


(A screenshot in Windows7 – use ‘Turn Windows features on or off’ in Control Panel, and use Server Manager for Windows 2008)


(Run Server Manager –> Add Roles(Web Server) –> Select Role Services –> Install)

Before describing details of HTTP compression in IIS7.x, let me explain one thing important about IIS7.x.

In IIS6, one of principles of product design, is ‘not enabled by default’, in order to secure web servers from its initial installation. For example, ASP(Active Server Pages) is not enabled after IIS6 installation by default. For the similar reason, IIS7.x has a principle, which is ‘not installed by default’. You will find that there’re many features to add after its default installation, such as adding a role, features.

In IIS7, many things have changed. Basically, you can see the IIS manager which has very different UI(User Interface) with IIS6, and the new UI is very supportive to apply any settings in a global level, or site, or folder, or applications, or file level. Many of settings can be applied for a file only, or server-wide. I’m going to post an article about changes of IIS7, but this time, I’d like to let you know a scope of any IIS settings for your better understanding.

To make easier to read, I’m going to use a word IIS7 instead of ‘IIS7 & IIS7.5’ from now on.

Now, you found that HTTP Compression requires adding features, and it can be applied in various levels. If you can’t find ‘Compression’ feature in IIS manager, check compression modules installed under ‘Performance features’ of Web Server role. Just like an IIS6, installing compression modules is just a first step to complete compression settings.


To enable HTTP compression globally in IIS, click the server name, and double-click Compression in the right pane.


To enable HTTP compression in a site or folder level, select a site in IIS manager, and double-click Compression icon in the right pane.


After enabling static content compression, you need to check & configure a path to store compressed files(cache).


‘appcmd’ is a main configuration tool in IIS7, that works in a command prompt. It is located in ‘c:\windows\system32\inetsrv’ folder. Please take a note this because any articles from Microsoft are not kind enough.

This information for using ‘appcmd’ commands are just for your information. I recommend to use IIS Manager, and edit configuration files directly to configure details of IIS settings, instead of using ‘appcmd’, because I don’t want to waste my time to explain why commands don’t work well, cause errors, and mistakes happen when you use appcmd.

Problems of using appcmd, are not because appcmd has a bug, but because you need to know IIS configuration hierarchy with its schema. If you decided to use APPCMD tool to configure IIS settings, I just wish you good luck.

To configure static content compression settings, use the following syntax:

appcmd set config /section:urlCompression
int /directory:string /maxDiskSpace:int

The variable minFileSizeforComp int sets the minimum number of bytes a file must contain for it to be compressed. The default value is 256. The variable directory string specifies the directory where compressed versions of static files are temporarily stored and cached. The default is %SystemDrive%\inetpub\temp\IIS Temporary Compressed Files. The variable maxDiskSpace int sets the maximum amount of space per application pool, in megabytes, you want IIS to use when it compresses static content. The default is 100 MB per application pool.

Configure Compression(IIS7) http://technet.microsoft.com/en-us/library/cc730629(v=ws.10)

Configuring HTTP Compression in IIS 7



In this step, you need to review and add required MIME types to be compressed, review the below in applicationhost.config file, located in c:\Windows\System32\Inetsrv\Config. Note that when you edit applicationhost.config manually, without specifying a scope(folder, site), it will be applied for IIS global settings. HttpCompression is one thing to be applied globally.


<httpCompression directory=”%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files”>
    <scheme name=”gzip” dll=”%Windir%\system32\inetsrv\gzip.dll” />
        <add mimeType=”text/*” enabled=”true” />
        <add mimeType=”message/*” enabled=”true” />
        <add mimeType=”application/x-javascript” enabled=”true” />
        <add mimeType=”*/*” enabled=”false” />
        <add mimeType=”text/*” enabled=”true” />
        <add mimeType=”message/*” enabled=”true” />
        <add mimeType=”application/javascript” enabled=”true” />
        <add mimeType=”*/*” enabled=”false” />

In IIS6, after enabling compression, you can add required extensions, such as ‘ASPX’, manually. In IIS7, you need to add ‘MIME TYPES’ instead of extensions. You can also refer IIS Manager to review MIME Types if you’re not sure extensions to be added,


Open ‘MIME Types’ in IIS Manager to review MIME types with extensions.


If you want to enable, or disable HTTP Compression in a site level, select the site in IIS Manager, and open ‘Compression’ feature to enable, or disable. Once you made a change in a site, or folder level, you’ll have web.config file in a root folder of the site, or the folder you selected. You can edit the web.config file, and it’s okay to copy the file to other locations to replicate settings. A web.config file in a site, or folder level can be created like below after making changes in IIS Manager,

<?xml version=”1.0″ encoding=”UTF-8″?>
        <urlCompression doStaticCompression=”true” />


So, you can see there’s no machine specific information, or physical path there, so you can copy & paste it to other locations, if necessary. But you need to make sure it before replicating.

In HTTP Compression in a site, or folder level, uses <urlCompression> element which is to enable, or disable compression only. For more details of <urlCompression> element, you can refer http://www.iis.net/ConfigReference/system.webServer/urlCompression


It’s almost done. Before finishing this article, I’d like to let you know a new feature of IIS7, which can be useful when you enable HTTP compression. It’s ‘HTTP Compression on the fly’.

‘Compression on the fly’ means compression can be enabled, or disabled, based on CPU utilization of IIS server. dynamicCompressionDisableCpuUsage, and dynamicCompressionEnableCpuUsage under <httpCompression> element, are attributes to enable, or disable on the fly. Please edit applicationhost.config file directly, because IIS manager doesn’t have this in its UI by default, and using ‘appcmd commands’ requires your good luck.

Because one of concerns to use HTTP Compression feature, can be CPU overhead to compress responses in IIS server. In terms of static contents, CPU overhead can be less because IIS can utilize a file cache(compressed files in the cache folder) after first compression of static contents. But in terms of dynamic contents, the output of applications should be compressed every time. So, ‘compression on the fly’ is one thing you can consider for compression of dynamic contents.

For more details of <httpCompression> attributes, you can refer http://www.iis.net/ConfigReference/system.webServer/httpCompression

Categories: IIS Stories
  1. No comments yet.
  1. 2014/09/30 at 8:34 pm

Leave a Reply

Fill in your details below or click an icon to log in:

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

%d bloggers like this: