Analysis of GZip configuration parameters in Nginx server
This article mainly introduces the detailed explanation of GZip configuration parameters in Nginx server, that is, using GZip to compress website page data. Friends in need can refer to it
gzip (GUN-ZIP) is a compression technology , the page size after gzip compression can be reduced to 30% or less of the original size.
Users will browse the page faster. The gzip compressed page needs to be supported by both the server and the browser. The server-side compression is transmitted to the
browser for decompression and parsing. Now most Most browsers already support parsing gzip pages
gzip usage environment: http, server, location, if (x), generally I define it in http{…..} of nginx.conf Time
gzip on;
Turn on gzip off off
gzip_min_length 1k;
Set the minimum page bytes allowed for compression ( Obtained from the Content-Length of the header header) It is recommended to be greater than 1k
gzip_buffers 4 16k;
is based on 16k as the unit, and applies for memory in 4 times the original data size in 16k as the unit
gzip_http_version 1.1;
Identify the version of http protocol. Early browsers may not support gzip self-extraction, and users will see garbled characters
gzip_comp_level 2;
Level 1-9 The smallest compression is the fastest but consumes cpu
gzip_types text/plain application/x-javascript text/css application/xml;
Match compression type
gzip_vary on;
Enable response header "Vary: Accept-Encoding"
gzip_proxied off;
Enable when nginx is used as a reverse proxy, off (turn off the compression of all proxy result data), expired (enable compression, if the header header includes "Expires" header information), no-cache (enable compression, in the header header) Contains "Cache-Control: no-cache"), no-store (enables compression, the header contains "Cache-Control: no-store"), private (enables compression, the header contains "Cache-Control: private" ), no_last_modefied (enable compression, the header does not contain "Last-Modified"), no_etag (enable compression, if the header does not contain "Etag" header information), auth (enable compression, if the header contains "Authorization" header information)
gzip_disable msie6;
(IE5.5 and IE6 SP1 use the msie6 parameter to disable gzip compression) Specify which browsers do not require gzip compression (will be used with User- Agents for matching), relying on the PCRE library
##gzip
Determine whether to enable the gzip moduleexample:
gzip on;
gzip_buffers
Set the size of memory requested by gzip. Its function is to apply for memory space in multiples of the block size. param2:int(k) The following unit is k
example:
gzip_buffers 4 8k;
gzip_comp_level
Set the gzip compression level. The lower the level, the faster the compression speed and the smaller the file compression ratio. On the contrary, the slower the speed, the larger the file compression ratio. param:1-9
example:
gzip_com_level 1;
gzip_min_length
When the returned content is greater than this value, gzip will be used for compression, in K, when the value is 0, all pages will be compressedparam:int
example:
gzip_min_length 1000;
gzip_types
Set the MIME type that needs to be compressed, non-set values will not be compressedparam:text/html|application/x-javascript|text/ css|application/xml
example:
gzip_types text/html;
How to quickly view nginx configuration files
The above is the detailed content of Analysis of GZip configuration parameters in Nginx server. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

How to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.

How to configure an Nginx domain name on a cloud server: Create an A record pointing to the public IP address of the cloud server. Add virtual host blocks in the Nginx configuration file, specifying the listening port, domain name, and website root directory. Restart Nginx to apply the changes. Access the domain name test configuration. Other notes: Install the SSL certificate to enable HTTPS, ensure that the firewall allows port 80 traffic, and wait for DNS resolution to take effect.

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

The methods that can query the Nginx version are: use the nginx -v command; view the version directive in the nginx.conf file; open the Nginx error page and view the page title.

Create a container in Docker: 1. Pull the image: docker pull [mirror name] 2. Create a container: docker run [Options] [mirror name] [Command] 3. Start the container: docker start [Container name]

Docker container startup steps: Pull the container image: Run "docker pull [mirror name]". Create a container: Use "docker create [options] [mirror name] [commands and parameters]". Start the container: Execute "docker start [Container name or ID]". Check container status: Verify that the container is running with "docker ps".

Starting an Nginx server requires different steps according to different operating systems: Linux/Unix system: Install the Nginx package (for example, using apt-get or yum). Use systemctl to start an Nginx service (for example, sudo systemctl start nginx). Windows system: Download and install Windows binary files. Start Nginx using the nginx.exe executable (for example, nginx.exe -c conf\nginx.conf). No matter which operating system you use, you can access the server IP
