前言
为了提高页面的响应
nginx实现
gzip on;
gzip_min_length 1k; #不压缩临界值,大于1K的才压缩
gzip_buffers 4 16k;
#gzip_http_version 1.0;
gzip_comp_level 2; #压缩等级,越大压缩的越小
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;#压缩类型
gzip_vary off;
gzip_disable "MSIE [1-6]\."; #不压缩IE1-6
检验
curl -I -H "Accept-Encoding: gzip, deflate" http://192.168.0.194:801/admin1/static/imgs/phone/web1x/phone.png
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 27 Sep 2019 08:53:16 GMT
Content-Type: image/png
Last-Modified: Fri, 27 Sep 2019 08:34:17 GMT
Connection: keep-alive
ETag: W/"5d8dc989-feb"
Content-Encoding: gzip
网友评论