Enable HTTP compression (GZip compression) in IIS6

Source: Internet
Author: User

IIS compression is not a new technology, but for websites, IIS compression can play a major role. After the IIS compression function is enabled on the IIS server, before the IIS server sends the page content to the browser, It compresses the content on the server and then sends the compressed data, after the browser receives the data, it automatically decompress it and then displays it. Because the data transmitted over the network is compressed, the page content can be transmitted to the browser faster to improve the page browsing speed.

Although it takes some CPU time to compress the page content on the IIS server, this does not cause any problems for the CPU of mainstream servers. In addition, the CPU time is too low compared with the data transmission time saved. After a static content page is compressed each time, IIS will cache the compressed files to the disk, which can avoid repeated compression next time, so it will not put too much burden on the CPU. If you find that it does not improve the server performance, it is very easy to disable it. It has not changed the content of your site, but only the data transmission method.

Enabling IIS compression on the IIS server can be done through the IIS manager on the GUI, but some configurations cannot be done only through the IIS manager, we use a script tool of IIS for all management and configuration.

Open the IIS management interface and right-click the "website" tab-> properties.
"HTTP compression" under the "service" label ":
Select "compressing Application Files" or "compressing static files" as needed ".
The folder corresponding to the Temporary directory, usually "C: \ WINDOWS \ IIS Temporary Compressed Files". You must grant the IUSR _ machine name write permission.

The following commands must be executed at the command prompt on the server.

Enable static file (.js).css).html and so on) compression on iisserver:
Cscript C: \ Inetpub \ adminscripts \ adsutil. vbs set w3svc/filters/compression/parameters/HcDoStaticCompression true

Enable dynamic file (. asp) compression on the IIS server:
Cscript C: \ Inetpub \ adminscripts \ adsutil. vbs set w3svc/filters/compression/parameters/HcDoDynamicCompression true

To add the ". js" and ". css" file types to static File compression, run the following two commands:
Cscript C: \ Inetpub \ adminscripts \ adsutil. vbs SET W3Svc/Filters/Compression/DEFLATE/HcFileExtensions "htm" "html" "txt" "js" css"
Cscript C: \ Inetpub \ adminscripts \ adsutil. vbs SET W3Svc/Filters/Compression/GZIP/HcFileExtensions "htm" "html" "txt" "js" "css"

Add the ". aspx" file type to dynamic File compression (all pages of The SharePoint site are. aspx). Run the following two commands:
Cscript C: \ Inetpub \ adminscripts \ adsutil. vbs SET W3SVC/Filters/Compression/Deflate/HcScriptFileExtensions "asp" "dll" "exe" "aspx"
Cscript C: \ Inetpub \ adminscripts \ adsutil. vbs SET W3SVC/Filters/Compression/gzip/HcScriptFileExtensions "asp" "dll" "exe" "aspx"

Increase the default compression ratio by using two commands:
Cscript C: \ Inetpub \ adminscripts \ adsutil. vbs SET W3Svc/Filters/Compression/GZIP/HcDynamicCompressionLevel "9"
Cscript C: \ Inetpub \ adminscripts \ adsutil. vbs SET W3Svc/Filters/Compression/DEFLATE/HcDynamicCompressionLevel "9"

Finally, Run "iisreset" to restart IIS

In addition, you can modify the iis configuration database for the following purposes:

On the IIS Management page, right-click the computer name tab and choose Properties.
Select "allow direct configuration database editing"
Open "C: \ WINDOWS \ system32 \ inetsrv \ MetaBase. xml ",
In the <IIsCompressionScheme Location = "/LM/W3SVC/Filters/Compression/deflate"> section and <IIsCompressionScheme Location = "/LM/W3SVC/Filters/Compression/gzip"> section,
Modify HcDynamicCompressionLevel to 9. (Best performance/compression ratio)
Modify HcFileExtensions to "htm html txt js css" (extensible, with quotation marks)
Modify HcScriptFileExtensions to "asp exe dll aspx" (extensible, with quotation marks)
Save the file.
Disable the "allow directly edit configuration database" option.

How much data transmission can be saved after IIS compression is enabled? We can perform a simple test. We use Microsoft Fiddle, a useful and powerful tool. In principle, it is a proxy that allows the browser to obtain HTTP content. It automatically records the historical access data of the browser. You can download Fiddle at http://www.fiddlertool.com/fiddler/version.asp.

First, disable IIS compression, clear the browser cache, and then access the default site homepage in IE. The access history data recorded in Fiddle is as follows:

Request Count: 29
Bytes Sent: 11,089
Bytes encoded ed: 676,934

This information indicates that the browser requests a total of 29 Resources, and the server sends a total of K data to the browser. 676 K! This is only the default site homepage!

Enable the IIS compression function, clear the browser cache, and visit the home page again. The information recorded in Fiddle is as follows:

Request Count: 29
Bytes Sent: 11,089
Bytes encoded ed: 230,276

We can see that by simply enabling the IIS compression function, the data size requested by the default homepage is reduced from 676K to 230 K.

Ps: This article is reproduced and sorted online, and the following problems are found:

If it is ineffective to re-access the client after clearing the IE cache, you can use the application pool to reclaim resources.
Setting the HcScriptFileExtensions parameter to a null string will reduce server performance. (All dynamic responses are compressed)


Related HTTP compression Software: Port80 Software ZipEnable

ZipEnable is one of the few products recommended by Microsoft and is compatible with IIS 6. By configuring IIS 6 settings, it can further control IIS6's HTTP compression function at the directory level.

Test whether gzip is Enabled: www.port80software.com/tools/compresscheck

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.