开启gzip压缩可以提升网站打开速度,服务器配置低或者高的都可以开启,还可以减少访客丢失率。
打开nginx配置文件nginx.conf
或者之前命令编辑
vim /usr/local/nginx/conf/ nginx.conf
增加配置:
gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; #gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss; gzip_types text/plain application/x-<a href="/js_a/js.html" target="_blank">javascript</a> text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\.";
细心的可以看到其实只是替换了原有的这段
#gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss;
为
gzip_types text/plain application/x-<a href="/js_a/js.html" target="_blank">javascript</a> text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
查看是否开启gzip
文章评论(0)