Observe that we opened a news article from 163, and saw the following corresponding header information, and saw the following response header information. Note, Content-Length
At the same time, we Right-click to save the source code. The saved file size is
Thinking: Content-LengthIn the previous study, it represented the returned body length
But why are the body length and content-length returned here? What about inconsistencies?
The reason is thatContent-Encoding:gzipThis response header information is working
Principle: In order to improve the transmission speed of web pages on the network, the server compresses the main information. Such as the commongzip compression, deflate compression, compress compression, and the sdch compression that google chrome is pushing.
The compression process is like this:is the length after "compression"
How to enable it inapache Compression function?
1. Enable thedeflate module, or the gzip module.
2.Write the following code in the conf file
3. Why do you need to specify the file type for compression? Answer: Compression also consumes
CPU resources, and the compression effect is not good for pictures /movies/videos and other files.
It is generally a file in compressed text format.<ifmodule mod_deflate.c> DeflateCompressionLevel 6 AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/javascript AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/atom_xml AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/x-httpd-php AddOutputFilterByType DEFLATE image/svg+xml </ifmodule>
?
Answer: The client is allowed to send anaccept-Encoding header message to negotiate with the server
This example can show the three types of chromebrowsers
Firefox only supports two compression methods Tips: When we are collecting, we don’t need to send the Accept-Encodinginformation, so that the source code is collected directly. Of course, we can also collect gzip (increase speed), and then use gzipDecompress the content.