fix(nginx): 去掉 immutable + 缩短缓存 · 迭代期 CSS/JS 改了团队能立刻看到
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 9s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 9s
This commit is contained in:
parent
e7c0a14f75
commit
704ef9a954
@ -14,10 +14,23 @@ server {
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
|
||||
|
||||
# Cache static assets (CSS/JS/images/fonts)
|
||||
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|mp4|webm)$ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
# 设计稿迭代期:CSS/JS 不带 hash,不能用 immutable,否则改了浏览器仍吃旧版
|
||||
# 缓存 1 小时 + must-revalidate(过期后用 If-Modified-Since 回源验证,服务器没改返回 304,改了取新文件)
|
||||
location ~* \.(css|js)$ {
|
||||
expires 1h;
|
||||
add_header Cache-Control "public, must-revalidate";
|
||||
}
|
||||
|
||||
# 图片/字体/媒体:可以缓存稍长(改动频率低),仍允许重新验证
|
||||
location ~* \.(png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|mp4|webm)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, must-revalidate";
|
||||
}
|
||||
|
||||
# HTML:不进浏览器磁盘缓存,每次都问服务器有没有新版本
|
||||
location ~* \.html$ {
|
||||
add_header Cache-Control "no-cache, must-revalidate" always;
|
||||
expires off;
|
||||
}
|
||||
|
||||
# Multi-page (not SPA): try exact file, then .html fallback (friendly URLs), then 404.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user