Heim > Fragen und Antworten > Hauptteil
gzip压缩的配置生效了。缓存的配置没有生效
网上各种配置都是没有指明在哪里配置等细节[我是前端开发....]
在nginx.conf配置文件的server对象中新增
server{
//新增配置
location ~ .*\.(js|css)?$
{
expires 3d;
}
}
对应的js请求报文中没有生效:
Response Headers
view source
Connection:keep-alive
Content-Encoding:gzip
Content-Type:application/javascript
Date:Wed, 08 Mar 2017 13:19:47 GMT
ETag:W/"58bfcc22-e782e"
Last-Modified:Wed, 08 Mar 2017 09:17:22 GMT
Server:nginx/1.10.1
Transfer-Encoding:chunked
Vary:Accept-Encoding
Request Headers
view source
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:zh-CN,zh;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Host:120.132.3.52:8088
Pragma:no-cache
Referer:http://120.132.3.52:8088/uci-pre/build/vue-dev/page.html
User-Agent:Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1
PHPz2017-04-18 10:52:09
楼主问题解决了嘛,我也遇到类似的问题,网上千篇一律的配置,试了好几个也不行,以下是我现在的配置,我的站点是 www.jhipster.cc
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css|json)$ {
expires 30d;
access_log off;
}