Configure Compression (IIS 7)
Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista
Configure HTTP compression to use bandwidth more efficiently and to enhance the performance of sites and applications. By compressing static or dynamic content, customers using compression-compatible browsers with low bandwidth connections, such as dial-up modems, can experience faster download times.
Note
If you already have a network-based compression solution installed, enabling compression in IIS might not give you increased bandwidth utilization or performance improvements, depending on whether the network-based compression and IIS-based compression are redundant.
Note
Adding a configuration setting adds the setting at the local level and to any child levels that inherit the setting.
Prerequisites
For information about the levels at which you can perform this procedure, and the modules, handlers, and permissions that are required to perform this procedure, see HTTP Compression Feature Requirements (IIS 7).
Exceptions to feature requirements
Levels
- Web server
Required Permissions
- Web server administrator
To configure compression
You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.
User Interface
To Use the UI
Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI, see Navigation in IIS Manager (IIS 7).
In Features View, double-click Compression.
Choose one or both of the following:
Enable dynamic content compression to configure IIS to compress dynamic content.
Enable static content compression to configure IIS to compress static content.
If Enable static content compression is selected, under Static Compression,
In the Only compress files larger than (in bytes) text box, type the minimum file size that you want IIS to compress. The default size is 256 bytes.
In the Cache directory text box, type the path of a local directory or click the browse button (…) to locate a directory. After a static file is compressed, it is cached in this temporary directory until it expires, or until the content changes. The temporary directory must be on a local drive on an NTFS-formatted partition. The directory cannot be compressed, and should not be shared.
Optionally, select the box next to Per application pool disk space limit (in MB) and type the maximum amount of space per application pool, in megabytes, you want IIS to use when it compresses static content. For example, if there are 20 application pools on the server and the Disk space limit is set to 100, the maximum disk space will be 2GB. If you click the Per application pool disk space limit (in MB) option and type a number in the text box under it, IIS automatically cleans up the temporary directory according to a least recently used rule when the set limit is reached. The default is 100 MB per application pool.
Click Apply in the Actions pane.
Command-line
Enable dynamic content compression
To enable HTTP compression of dynamic content, at the command prompt, type the following command, and then press Enter:
appcmd set config /section:urlCompression /doDynamicCompression:True
Enable static content compression
To enable HTTP compression of static content, at the command prompt, type the following command, and then press Enter:
appcmd set config /section:urlCompression /doStaticCompression:True
Configure static content compression settings
To configure static content compression settings, use the following syntax:
**appcmd set config /section:urlCompression /minFileSizeforComp:**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.
For more information about Appcmd.exe, see Appcmd.exe (IIS 7).
Configuration
The procedure in this topic affects the following configuration elements:
<httpCompression>
<urlCompression>
For more information about IIS 7 configuration, see IIS 7.0: IIS Settings Schema on MSDN.
WMI
Use the following WMI classes, methods, or properties to perform this procedure:
- HttpCompressionSection class
For more information about WMI and IIS, see Windows Management Instrumentation (WMI) in IIS 7. For more information about the classes, methods, or properties associated with this procedure, see the IIS WMI Provider Reference on the MSDN site.