nginx 开启 gzip 压缩

gzip 可以在 http 块 或者 server 块中配置,一般用于压缩静态资源(图片不建议使用gzip压缩)。

http {
  # ... before

  gzip on;
  gzip_buffers 32 4K;
  gzip_comp_level 6;
  gzip_min_length 100;
  gzip_types application/javascript text/css text/xml;
  gzip_disable "MSIE [1-6]\.";
  #配置禁用gzip条件,支持正则。此处表示ie6及以下不启用gzip(因为ie低版本不支持)
  gzip_vary on;

  # ...after
}