What is gzip
GZIP is the acronym for GUNZIP, the earliest file compression applied to UNIX systems. The gzip encoding on the HTTP protocol is a technique used to improve the performance of Web applications, and both the Web server side and the client must support gzip. The current mainstream browsers support the protocol, and common server Apache,nginx,iis also support gzip.
Gzip reduces the bandwidth of the server by replacing compression with a similar portion of the file, which is usually around 3 to 10 times times the compression ratio. In practical applications, we mainly compress the static files such as. Js,.css,.json.
So how does the client and the server communicate to support gzip? First, when the client sends an HTTP request, it takes the request header accept-encoding and sets its value to gzip. Indicates that the browser supports gzip. After receiving the request, the server determines whether the browser supports gzip, and if so, sends the compressed content to the browser or sends the uncompressed content. Typically, both the server side and the browser support gzip. The contents returned by the response header contain content-encoding:gzip.
After the browser receives a response from the server, it determines whether the response is compressed. If it is compressed, unzip and then show the content.
the principle is shown in the following illustration:
how to turn on gzip in IIS
Our server here uses Windows Server, and the IIS version is v8.5.
First, open IIS Manager, navigate to the appropriate site, select the function view, click Compress.
If prompted for dynamic content compression is not installed, open Server Manager, click Management, select Add roles and features.
Tick server Roles > Web server > Performance > Dynamic content compression. For installation.
After installation, click on the server interface, click the Configuration Editor.