问题描述:
在linux下的nginx配置拦截html,并设置不缓存,js,css,jpg,png等静态资源缓存30天;
备注:
我们服务器上的*.html和js,css,jpg等在同一级目录下
解决方案:
location / {
alias 请求路径;
index index.html;
if ($uri ~* .*\.(?:htm|html)$){
add_header Cache-Control "no-store, no-cache";
}
if ($uri ~* .*\.(?:js|css|jpg|png)$){
expires 7d;
}
}