Enable gzip compression for IIS
The modern browsers IE6 and Firefox both support the client gzip. That is to say, before the webpage on the server is transmitted, Gzip compression is used before it is transmitted to the client. After receiving the webpage, the client is decompressed and displayed by the browser, in this way, although the CPU usage of some servers and clients is slightly occupied, the bandwidth utilization is higher. For plain text, the compression ratio is considerable. If each user saves 50% of the bandwidth, the bandwidth you lease will be able to serve customers more than doubled.
IIS6 has built-in support for gzip compression. Unfortunately, there is no better management interface. It takes some effort to enable this option.
First, if you need to compress static files (HTML), you need to create a directory on the hard disk and give it the write permission of the user "IUSR _ machine name. It is not required to compress dynamic files (PHP, ASP, and aspx), because the pages are dynamically generated every time, so you can discard them after compression. In the IIS manager, right-click the website and choose "properties". The website is not the following site, but the whole website. Go to the "service" tab and choose to enable dynamic content compression and static content compression.
Select the Server Extension under the website and create a new server extension. The name does not matter. The path of the file to be added below is:
C: \ windows \ system32 \ inetsrv \ gzip. dll and enable this extension.
Static content can be compressed at this time, but for dynamic content, the aspx file is not within the compression range. Because the default file that can be compressed does not have this extension. On the management interface, you cannot find a place where the extension can be added. At this time, you can only modify its configuration file.
There is a metabase. xml file under c: \ windows \ system32 \ inetsrv \. You can open it in notepad and find iiscompressionscheme, which has three segments with the same name,
They are
- <Iiscompressionscheme location = "/lm/w3svc/filters/compression/deflate"
- <Iiscompressionscheme location = "/lm/w3svc/filters/compression/gzip"
- <Iiscompressionschemes location = "/lm/w3svc/filters/compression/parameters"
You don't need to worry about it in the third section. The first two sections have basically the same parameters. Add a line of aspx under the parameters hcscriptfileextensions. If you have other dynamic programs to compress, it is also added here. Change hcdynamiccompressionlevel to 9 (0-10, 9 is the most cost-effective ).
Note:
- HcfileextensionsSpecifies the file extension supported by the compression scheme. IIS only compresses static files with the specified file extension. If this parameter is set to null, static files are not compressed.
- HcscriptfileextensionsSpecifies the file extension supported by the compression scheme. IIS compresses the dynamic file output using the file extension specified by this attribute.
- HcdynamiccompressionlevelAttribute specifies the compression level of the compression scheme for compressing dynamic content. A slightly larger compressed file is generated at the lower compression level, but the overall impact on CPU and memory resources is small. The high compression level usually generates small compressed files, but it takes a lot of CPU time and memory.
- HcondemandcomplevelAttribute specifies the compression level of the compression scheme when static content is compressed as needed. A slightly larger compressed file is generated at the lower compression level, but the overall impact on CPU and memory resources is small. The high compression level usually generates small compressed files, but the CPU and memory usage is high.
- HcpriorityAttribute specifies the priority assigned to a specific compression scheme. If you install multiple compression schemes when installing IIS, and the client browser specifies in the accept-encoding header that can process multiple compression schemes, IIS will use Hcpriority Specifies the priority number to determine the scheme used by the request. In this case, IIS uses a matching scheme with the highest priority. Valid priority numbers range from 1 to 10. Generally, if multiple compression schemes are installed on IIS, you should assign a different priority number for each compression scheme.
Then you need to restart the IIS service to realize the compression speed. But usually may not have too obvious feeling, you can use http://www.port80software.com/tools/compresscheck.asp (English) http://gzip.zzbaike.com/(Chinese) this page to check whether your web page is compressed, as well as the compression ratio and speed up. The CPU usage in the whole process is basically invisible.