Home > Backend Development > PHP Tutorial > nginx configuration gzip

nginx configuration gzip

WBOY
Release: 2016-07-29 08:55:49
Original
1401 people have browsed it

开1, Vim opens the nginx configuration file

vim /usr/local/nginx/conf/nginx.conf

2, find the following paragraph, modify

gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
#gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary off;
gzip_disable "MSIE [1-6].";3. Explain

Line 1: Turn on Gzip

Line 2: No compression threshold, greater than Only 1K is compressed, and generally there is no need to change it.

Line 3: buffer is, well, forget it, I won’t explain it, no need to change it

Line 4: If a reverse proxy is used, the terminal communication is HTTP/1.0, if necessary You shouldn’t need to read my popular science article; if you have this sentence, just comment it. The default is HTTP/1.1

Line 5: Compression level, 1-10. The larger the number, the better the compression and the longer the time. , feel free to change it depending on your mood

Line 6: The file type to be compressed, just fill in whatever is missing. There are two ways to write JavaScript, it is best to write them both. There are always people who complain that js files are not compressed. In fact, write one more Just use this format

Line 7: It is related to caching services such as Squid. If it is on, "Vary: Accept-Encoding" will be added to the Header. I don't need this thing. I can figure it out by myself.

Line 8 : IE6 is not very friendly to Gzip and does not give it Gzip anymore

4. Reload Nginx

/usr/local/nginx/sbin/nginx -s reload

5. Use curl to test whether Gzip is successfully turned on

Content -Encoding: gzip

The above introduces nginx configuration gzip, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template