Nginx enables gzip compression and nginx enables gzip
1) Vim open the Nginx configuration file
Vim/usr/local/nginx/conf/nginx. conf
2) locate the following section and modify it.
# Enable Gzip
Gzip on;
# No compression critical value. compression is required if the compression value is greater than 1 kb.
Gzip_min_length 1 k;
Gzip_buffers 4 16 k;
# Gzip_http_version 1.0;
# Compression level, 1-10, the larger the number, the better the compression, the longer the time
Gzip_comp_level 4;
# Types of files to be compressed
Gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
# It is related to cache services such as Squid. If on is used, "Vary: Accept-Encoding" will be added to the Header"
Gzip_vary off;
# IE6 not compressed
Gzip_disable "MSIE [1-6] \.";
Static files in nginx + php are not compressed by gzip.
Use the nginx + php integration package phpfind or phpstudy. Extract the pure Chinese text in green. Try it. It is super simple and automatically equipped with the nginx + php environment.
My server is an eight-core linux server and uses nginx as a reverse proxy. If gzip support is enabled, will it cause high CPU consumption on the server?
Cpu usage is required.
However, gzip does not occupy high computing resources.
However, we need to consider your specific situation.
For example, traffic, memory, cpu usage of other parts of the application, etc.
Such a general question and answer is meaningless ..
You can test it yourself.