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.
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.
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.