Nginx开启Gzip压缩大幅提高页面加载速度
Posted 运维工匠实战(如果发现有错误请大家把正确的方法发送给我,方便
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Nginx开启Gzip压缩大幅提高页面加载速度相关的知识,希望对你有一定的参考价值。
[[email protected] conf]# vi nginx.conf gzip on;#开启GZIP gzip_min_length 1k; #不压缩临界值,大于1K的才压缩,一般不用改 gzip_buffers 4 16k; #gzip_http_version 1.0; gzip_comp_level 2;#压缩级别,1-10,数字越大压缩的越好,时间也越长 #gzip_types text/plain application/x-javascript text/css application/xml; gzip_types text/plain application/x-javascript text/css application/xmli text/javascript application/x-httpd-php image/jpeg image/gif image/png; gzip_vary off; gzip_disable "MSIZE [1-6]\.";#IE6对Gzip不怎么友好,不给它Gzip
service nginx reload [[email protected] conf]# curl -I -H "Accept-Encoding:gzip,deflate" "http://xinxianm.com" HTTP/1.1 200 OK Server: nginx/1.4.4 Date: Tue, 31 May 2016 01:01:45 GMT Content-Type: text/html; charset=utf-8 Connection: keep-alive X-Powered-By: PHP/5.5.7 Set-Cookie: ECS_ID=650aa6ce6b78e9803c78923affc6a98ad5cf9bd2; path=/ Cache-control: private Content-Encoding: gzip
[[email protected] conf]# curl -I -H "Accept-Encoding:gzip,deflate" "http://xinxianm.com/images/upload/Image/1_05%2875%29.jpg" HTTP/1.1 200 OK Server: nginx/1.4.4 Date: Tue, 31 May 2016 01:02:46 GMT Content-Type: image/jpeg Last-Modified: Tue, 12 Apr 2016 07:24:20 GMT Connection: keep-alive Expires: Thu, 30 Jun 2016 01:02:46 GMT Cache-Control: max-age=2592000 Content-Encoding: gzip
以上是关于Nginx开启Gzip压缩大幅提高页面加载速度的主要内容,如果未能解决你的问题,请参考以下文章