Nginx gzip压缩
location ~ .*\.(jpg|gif|png)$ { root /data/wwwroot/images; autoindex off; autoindex_localtime on; #显示的文件时间为文件的服务器时间 autoindex_exact_size off; #单位是kB或者MB或者GB gzip on; gzip_min_length 1k; #大于1K才压缩 gzip_buffers 4 16k; #压缩缓存区大小 gzip_http_version 1.1; gzip_comp_level 5; #压缩比率 1-9,越大压缩越好,消耗资源越大 gzip_vary on; #vary header支持 gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; #auth_basic "pic.wanggaoli.com"; #auth_basic_user_file conf/vhost/.htpasswd; }
#压缩前

gzip前
#压缩后

gzip后