gzip(GNU-ZIP)是一种压缩技术。 Nginx的压缩输出由一组gzip压缩指令来实现。 gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml gzip_vary on; 提供两段gzip压缩代码,供大家学习参考。 nginx配置gzip段1: 复制代码 代码如下:
gzip on;
gzip_min_length 1k; gzip_buffers 16 64k; gzip_http_version 1.1; gzip_comp_level 6; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; nginx配置gzip段2: 复制代码 代码如下:
# output compression saves bandwidth gzip on; gzip_http_version 1.1; gzip_vary on; gzip_comp_level 6; gzip_proxied any; gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; # make sure gzip does not lose large gzipped js or css files # see http://blog.leetsoft.com/2007/7/25/nginx-gzip-ssl gzip_buffers 16 8k; # Disable gzip for certain browsers. gzip_disable “MSIE [1-6].(?!.*SV1)”;
|