I. Summary
This article summarizes how to enable gzip compression for Web sites that are hosted by IIS, thereby reducing the network transmission size of your Web page and increasing the speed at which users can display pages.
Two. Preface.
The knowledge of this article is from the Internet collection and collation, mainly from the Chinese wiki. Gzip is critical when using YSlow to detect which optimizations are enabled on your Web site. Starting GIP compression will instantly reduce the size of your page's network traffic.
Three. HTTP Compression overview
HTTP compression is a way to transfer compressed text content between a Web server and a browser. HTTP compression uses a common compression algorithm such as gzip compression HTML, JavaScript, or CSS files. The biggest benefit of compression is that it reduces the amount of data transferred by the network, thereby increasing the access speed of the client browser. Of course, it will also add a little bit of server burden. Gzip is a more common kind of HTTP compression algorithm.
Four. HTTP Compression working principle
The Web server works with HTTP compression as follows:
After the 1.WEB server receives the HTTP request from the browser, check to see if the browser supports HTTP compression;
In the HTTP header where the user's browser sends the request, the "accept-encoding:gzip, deflate" parameter indicates that the gzip and deflate two compression algorithms are supported.
2. If the browser supports HTTP compression, the Web server checks the suffix name of the request file;
Both the static file and the dynamic file suffix startup need to be set in MetaBase.xml.
Static files need to be set: HcFileExtensions Metabase Property (click Jump to MSDN Description)
Dynamic files need to be set: HcScriptFileExtensions Metabase Property (click Jump to MSDN Description)
3. If the request file is a static file such as HTML, CSS, and the file suffix is compressed, the Web server checks the compressed buffer directory to see if the requested file has the latest compressed file;
4. If the compressed file of the requested file does not exist, the Web server returns the uncompressed request file to the browser and holds the compressed file of the request file in the compressed buffer directory;
5. If the latest compressed file of the request file already exists, then directly returns the compressed file of the request file;
6. If the request file is an ASPX dynamic file and the file suffix has compression enabled, the Web server dynamically compresses the content and returns to the browser, and the compressed content is not stored in the compressed cache directory.
Five. Enable HTTP compression in IIS
IIS does not support HTTP compression by default, and requires a simple configuration
1. Open Internet Information Services (IIS) Manager, right-click Web site-> properties, and select Services. In the HTTP Compression box, select Compress application files and compress static files, and set the maximum limit for temporary directories and temporary directories as needed;