Nginx 开启 gzip

Sep 21, 20181 min read

This post was last modified 2028 days ago, and some of the content may be outdated.

查看 nginx 配置文件路径

BASH

修改配置文件

BASH

http 区域中新增 gzip 配置

NGINX

逐行解释一下

  • 开启 Gzip
  • 大于 1K 的才压缩,一般不用改
  • 压缩级别,1-9,数字越大,压缩率越高,cpu 占用的也更多,我服务器比较渣,这里设置了 1
  • 进行压缩的文件类型
  • ie6 对 gzip 不怎么友好,就不给它压缩了
  • 添加 vary 响应头,给代理服务器用的

最后重启 nginx

BASH

HITS

LAST UPDATED

Sep 21, 2018
Made withbyXiaojun