Share via


Enabling HTTP Compression

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1

Introduction to and procedures for enabling HTTP compression using IIS Manager and command-line scripts.

You can enable HTTP compression server-wide or on a specific directory. HTTP compression improves bandwidth utilization and speeds up Web site performance. In addition, you can compress static or dynamic responses.

Important

You must be a member of the Administrators group on the local computer to perform the following procedure or procedures. As a security best practice, log on to your computer by using an account that is not in the Administrators group, and then use the runas command to run IIS Manager as an administrator. At a command prompt, type runas /user:Administrative_AccountName"mmc %systemroot%\system32\inetsrv\iis.msc".

Procedures

To enable global HTTP compression by using IIS Manager

  1. In IIS Manager, double-click the local computer, right-click the Web Sites folder, and then click Properties.

  2. Click theService tab, and in the HTTP compression section, select the Compress application files check box to enable compression for dynamic files.

  3. Select the Compress static files check box to enable compression for static files.

  4. In the Temporary directory box, type the path to a local directory or click Browse to locate a directory. Once a static file is compressed, it is cached in this temporary directory until it expires, or the content changes. The directory must be on the local drive of an NTFS–formatted partition. The directory cannot be compressed or shared, and the access control lists (ACLs) for the directory must include Full Control access to the identity of the application pool or to the IIS_WPG group.

  5. Under Maximum temporary directory size, click a folder size option. If you specify a maximum size under Limited to (in megabytes) (the default setting is 95 MB), then when the limit is reached, IIS automatically cleans up the temporary directory by applying the "least recently used" rule.

  6. Click Apply, and then click OK.

Important

You must be a member of the Administrators group on the local computer to run scripts and executables. As a security best practice, log on to your computer by using an account that is not in the Administrators group, and then use the runas command to run your script or executable as an administrator. At a command prompt, type runas /profile /user:MyComputer</STRONG>Administratorcmd to open a command window with administrator rights and then type cscript.exeScriptName (include the script's full path and any parameters).

To enable global HTTP compression by using Adsutil.vbs

  1. Open a command prompt.

  2. To enable dynamic compression, type the following at the command prompt and then press ENTER:

    cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true

  3. To enable static compression, type the following at the command prompt and then press ENTER:

    cscript adsutil.vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true

To enable HTTP Compression for Individual Sites and Site Elements

  1. To enable static compression for only a single directory, first disable global static compression (if it is enabled) and then enable static compression at that directory. For example, to enable static compression for a directory at https://www.contoso.com/Home/StyleSheets, perform the following steps:

    1. Disable global static compression by executing the following command at a command prompt:

    adsutil set w3svc/filters/compression/parameters/HcDoStaticCompression false

    1. Enable static compression at this directory by executing the following command at a command prompt:

    adsutil set w3svc/1/root/Home/StyleSheets/DoStaticCompression true

  2. To disable static compression for only a single directory, first enable global static compression (if it is disabled) and then disable static compression at that directory. For example, to enable static compression for a directory at https://www.contoso.com/Home/StyleSheets, perform the following steps:

    1. Disable global static compression by executing the following command at a command prompt:

    adsutil set w3svc/filters/compression/parameters/HcDoStaticCompression true

    1. Enable static compression at this directory by executing the following command at a command prompt:

    adsutil set w3svc/1/root/Home/StyleSheets/DoStaticCompression false