Nginx enables gzip compression and nginx enables gzip

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.