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
In IIS Manager, double-click the local computer, right-click the Web Sites folder, and then click Properties.
Click theService tab, and in the HTTP compression section, select the Compress application files check box to enable compression for dynamic files.
Select the Compress static files check box to enable compression for static files.
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.
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.
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
Open a command prompt.
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
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
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:
- Disable global static compression by executing the following command at a command prompt:
adsutil set w3svc/filters/compression/parameters/HcDoStaticCompression false
- Enable static compression at this directory by executing the following command at a command prompt:
adsutil set w3svc/1/root/Home/StyleSheets/DoStaticCompression true
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:
- Disable global static compression by executing the following command at a command prompt:
adsutil set w3svc/filters/compression/parameters/HcDoStaticCompression true
- Enable static compression at this directory by executing the following command at a command prompt:
adsutil set w3svc/1/root/Home/StyleSheets/DoStaticCompression false
Related Information
For a detailed discussion of how HTTP compression works, how to test compression, and detailed compression configuration options, see Using HTTP Compression for Faster Downloads.
For more information about improving the performance of IIS network resources using related features like bandwidth throttling and connection timeouts, e Administering Network Resources.
For information about configuring the types of files IIS compresses server-wide, see Customizing the File Types IIS Compresses.