1. HTTP compression Overview
HTTP CompressionIt is a method for transmitting compressed text content between the Web server and the browser.HTTP CompressionCommon compression algorithms such as gzip are used to compress HTML, JavaScript, or CSS files.
2. 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. Configure HTTP compression in IIS 6.0
To configure HTTP compression in IIS 6.0, follow these steps:
- Open the Internet Information Service (IIS) manager, right-click "website"-> "properties", and select "service ". In the "HTTP compression" box, select "compressing Application Files" and "compressing static files", and set "temporary directory" and "maximum temporary directory limit" as needed ";
- In the Internet Information Service (IIS) manager, right-click "Web Service extension"-> "to 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 ";
- 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;
- 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;
- Finally, restart IIS. You canHTTP compression test websiteVerification result.