java - nginx expires 配置 无效?
问题描述
gzip压缩的配置生效了。缓存的配置没有生效网上各种配置都是没有指明在哪里配置等细节[我是前端开发....]
在nginx.conf配置文件的server对象中新增
server{
//新增配置 location ~ .*.(js|css)?${ expires 3d;}
}
对应的js请求报文中没有生效:
Response Headersview sourceConnection:keep-aliveContent-Encoding:gzipContent-Type:application/javascriptDate:Wed, 08 Mar 2017 13:19:47 GMTETag:W/'58bfcc22-e782e'Last-Modified:Wed, 08 Mar 2017 09:17:22 GMTServer:nginx/1.10.1Transfer-Encoding:chunkedVary:Accept-EncodingRequest Headersview sourceAccept:*/*Accept-Encoding:gzip, deflate, sdchAccept-Language:zh-CN,zh;q=0.8Cache-Control:no-cacheConnection:keep-aliveHost:120.132.3.52:8088Pragma:no-cacheReferer:http://120.132.3.52:8088/uci-pre/build/vue-dev/page.htmlUser-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

问题解答
回答1:location ~ .*.(js|css)?$
后面多个问号做啥
回答2:楼主问题解决了嘛,我也遇到类似的问题,网上千篇一律的配置,试了好几个也不行,以下是我现在的配置,我的站点是 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;}
相关文章:

网公网安备