Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation and configuration of gzip module of nginx

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1. The function of gzip module

The gzip module must be opened in both test and production environments. This module can efficiently compress the content of the page, whether html or css, js or pictures, saving bandwidth resources, improving the loading speed of the website and bringing better service to visitors.

2. Enable gzip

Just configure it in nginx's configuration file nginx.conf.

In http {

Gzip on

Gzip_min_length 1k

Gzip_buffers 4 32k

Gzip_http_version 1.1

Gzip_comp_level 6

Gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml

Gzip_vary on

} module to add

3. Detailed explanation

Gzip on; enables compression. Default is off.

Gzip_min_length 1k; set the compression threshold. When set to 1k, it means that if the file to be compressed is less than 1k, it will be compressed.

Gzip_buffers 432k; sets the number and size of compressed buffers. 432k means to apply for four buffers with a size of 32k.

Gzip_http_version 1.1 identifies the version of the http protocol

Gzip_types text/plain text/css text/javascript

The application/javascript application/xml; gzip_types option is very important, which specifies the types of files that can be compressed. If a certain type of file is not compressed and does not work in practice, find the reason here.

Gzip_vary on; enables the response header "Vary: Accept-Encoding"

Gzip_comp_level 6; compression ratio, used to specify GZIP compression ratio, 1 compression ratio is the smallest, processing speed is the fastest, 9 compression ratio is the largest, the transmission speed is fast, but the processing is slow, and it consumes CPU resources.

Enabled when gzip_proxied off; nginx is a reverse proxy

Gzip_disable msie6; makes IE6 not applicable gzip,IE6 support for gzip is not good, you may see garbled.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report