npm install
- 配置path.json
- 运行gulp
- 编辑nginx.conf
gzip on;
gzip_min_length 1000;
gzip_buffers 4 16k;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/json application/javascript font/ttf application/octet-stream;
gzip_vary on;
gzip_disable "MSIE [1-6].";
-
重新加载Nginx ps -ef|grep nginx
/usr/sbin/nginx -s reload -
用curl测试Gzip是否成功开启
curl -I -H "Accept-Encoding: gzip, deflate" "http://xxx"
- 在server块前配置
map $sent_http_content_type $expires {
default off;
text/html epoch;
text/css max;
application/javascript max;
application/json max;
~image/ max;
}
html不缓存,js、json、图片等资源缓存
-
在server块里增加配置
expires $expires;
-
重新加载Nginx
/usr/sbin/nginx -s reload -
用curl测试 curl -I "http://xxx"