Css,js of the website, xml,html can use gzip compression when transmitting, improve the access speed,
The image on the website, video and other multimedia files, because the compression effect is not good, so for the picture does not need to support compression,
If you want to optimize, you can set the life cycle of the picture a bit longer, so that the client side to cache
In nginx.conf, the gzip configuration can be written in an HTTP segment, anywhere in the server section
Format is as follows
gzip on; Turn on the GZIP compression feature
Gzip_buffers 4k; or Gzip_buffers 8k; Here the table does not each compress 32 packs, each packet 4k size, sends to the client
Gzip_comp_level 6; This represents the compression level, can be 0 to 9 of any one, the higher the level, the smaller the compression, saving bandwidth resources, but also consumes CPU resources, so the general compromise of 6
Gzip_min_length 200; This means that if the file is less than 200 bytes, there is no compression, because it has no meaning, it is very small
Gzip_types text/css Text/xml Application/javascript; This indicates which types of files to compress, the text/html type is the default and does not need to write, if you do not know what type of file, you can find the file type in the Nginx directory,/var/mywww/nginx/conf/mime.types file records all can Compressed file types
Gzip_vary on; Can not write, indicating that I am transmitting data, to the client that I use GZIP compression
After the completion, save, exit, restart Nginx
As you can see, the file requested by the Web page is only 1.6K
and the actual file size is 4.5K (4500)
This diagram shows that the response header illustrates the use of gzip compression