nginx常见配置
指定文件不使用缓存
if ($uri ~* version\.js) {
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
add_header Pragma "no-cache";
add_header Expires "Mon, 26 Jul 1997 05:00:00 GMT";
}
version.js不使用缓存
cookie判断
set $default_index "index.html";
location = / {
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
# 本地文件开启
if ($cookie_lang = "tw") {
set $default_index "index-tw.html";
}
# 如果是根路径访问,重写到对应的首页
if ($uri = /) {
rewrite ^ /$default_index last;
}
try_files $uri $uri/ /index.html;
}
浙公网安备 33010602011771号