Enable gzip compression of IIS6)

Source: Internet
Author: User
Tags metabase

1. Http compression Overview

HTTP compression is used to transfer compressed text content between web servers and browsers. HTTP compression adopts common CompressionAlgorithmSuch as gzip to compress HTML, JavaScript, or CSS files. The biggest advantage of compression is that it reduces the amount of data transmitted over the network and increases the access speed of the client browser. Of course, it also adds a little load on the server. Gzip is a common HTTP compression algorithm.

This article introduces the HTTP compression method, which is set in windows, with the advantage of high efficiency.

Ii. How HTTP compression works

How the Web server processes HTTP compression is as follows:

After receiving the HTTP request from the browser, the web server checks whether the browser supports HTTP compression;
If the browser supports HTTP compression, the web server checks the suffix of the request file;
If the requested file is a static file such as HTML and CSS, the web server will check whether the latest compressed file of the requested file already exists in the compressed buffer directory;
If the compressed file of the request file does not exist, the web server returns the uncompressed request file to the browser and stores the compressed file of the request file in the compressed buffer directory;
If the latest compressed file of the request file already exists, the compressed file of the request file is directly returned;
If the requested file is a dynamic file such as aspx, the web server dynamically compresses the content and returns it to the browser. The compressed content is not stored in the compressed cache directory.

3. to configure HTTP gzip compression in IIS 6.0:

1) Open the Internet Information Service (IIS) manager, right-click "website"-> "properties", and select "service ". Select "compression application" in the "HTTP compression" box.ProgramFiles "and" compressed static files ", set" temporary directory "and" maximum temporary directory limit "as needed ";

2) in the Internet Information Service (IIS) manager, right-click "Web Service extension"-> "and add a new Web Service extension... ", enter the extension" HTTP compression "in the" New web service extension "box, and add" required file "to c: \ windows \ system32 \ inetsrv \ gzip. DLL, the Windows System directory may vary depending on your installation, select "set extension status to allow ";

3) Open c: \ windows \ system32 \ inetsrv \ metabase in the text editor. in XML format (backup is recommended), locate location = "/lm/w3svc/filters/compression/gzip". To Compress dynamic files, set hcdodynamiccompression to "true ", add the suffix of the dynamic file you want to compress in hcscriptfileextensions, such as Aspx. If you want to compress static files, set hcdostaticcompression and hcdoondemancompression to "true ", in hcfileextensions, add the extension names of the static files to be compressed, such as XML and CSS. hcdynamiccompressionlevel and hcondemandcomplevel indicate the compression ratio. The smaller the number, the lower the compression ratio;

4) Save the metabase. xml file after editing. If the file cannot be saved, IIS may be using the file. Open "start"-> "Administrative Tools"-> "service", stop "IIS Admin Service", and save the settings;

5) Finally, restart IIS. You can go to the HTTP compression test site to verify the results.

 

The advantage of gzip compression on Web pages is obvious. The first is to reduce the server bandwidth, and the second is to increase the speed at which users open the web page. Iwms has a built-in gzip compression function, but it is only valid for dynamic pages. If you have generated a static file and the server is IIS6 (Windows2003 or later), you can simply enable the gzip compression function provided by IIS through the content described below, experience the benefits of gzip compression.

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.

Before modification, we need to modify a configuration file. Before modification, stop the IIS service and Open c: \ windows \ system32 \ inetsrv \ metabase. XML. The file is large. Find the following information:

<Iiscompressionscheme location = "/lm/w3svc/filters/compression/gzip" hccompressiondll = "% WINDIR % \ system32 \ inetsrv \ gzip. DLL "compression =" 1 "hcdodynamiccompression =" true "compression =" true "hcdostaticcompression =" true "compression =" 0 "hcfileextensions =" htmhtmltxt "hcondemancomplevel =" 10 "hcpriority =" 1 "hcscriptfileextensions =" aspdllexe "> </iiscompressionscheme>

Add some file suffixes to be compressed. hcfileextensions is the extension of static files, and JS and CSS are added. hcscriptfileextensions is the extension of dynamic files, and aspx and hcdynamiccompressionlevel are added to 9, (0-10, 9 is the most cost-effective ).
Then you need to restart the IIS service to realize the compression speed. However, it may not be too obvious. The CPU usage in the whole process is basically invisible.

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.