次の方法で共有


Enabling HTTP Compression in IIS

 

The following submission was done by Kuba Njie, another services employee that I have had the extreme pleasure of working with. This was a great article and as such….

 

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.

 

Note
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 server 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 the Service 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, use the default location, or 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.

 

Note:

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

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

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

2.

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:

1.

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

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

2.

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

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

 

Note

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 information on configuring the types of files IIS compresses server-wide, see Customizing the File Types IIS Compresses.

Comments