Home Backend Development PHP Tutorial nginx configuration gzip

nginx configuration gzip

Jul 29, 2016 am 08:55 AM
application gzip javascript nginx quot

开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.

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to allow external network access to tomcat server How to allow external network access to tomcat server Apr 21, 2024 am 07:22 AM

How to allow external network access to tomcat server

What are the nginx start and stop commands? What are the nginx start and stop commands? Apr 02, 2024 pm 08:45 PM

What are the nginx start and stop commands?

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

How to run thinkphp

Welcome to nginx!How to solve it? Welcome to nginx!How to solve it? Apr 17, 2024 am 05:12 AM

Welcome to nginx!How to solve it?

How to register phpmyadmin How to register phpmyadmin Apr 07, 2024 pm 02:45 PM

How to register phpmyadmin

How to deploy nodejs project to server How to deploy nodejs project to server Apr 21, 2024 am 04:40 AM

How to deploy nodejs project to server

How to solve the problem of nginx when accessing the website How to solve the problem of nginx when accessing the website Apr 02, 2024 pm 08:39 PM

How to solve the problem of nginx when accessing the website

How to communicate between docker containers How to communicate between docker containers Apr 07, 2024 pm 06:24 PM

How to communicate between docker containers

See all articles