构建产物文件名不带内容哈希,一年免验证的缓存策略导致每次蓝绿发布后 浏览器和CDN都会继续吃旧版本,用户需要清缓存或开无痕窗口才能看到更新。 改为no-cache后浏览器/CDN每次都会带条件请求向源站确认,未变化时只是 一次很快的304,一旦文件真的变了会立刻拿到新内容,不再需要手动清缓存。
25 lines
696 B
Nginx Configuration File
25 lines
696 B
Nginx Configuration File
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name _;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Tinode webapp uses hash-based client-side routing, so any unknown path
|
|
# can safely fall back to index.html.
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# Filenames here aren't content-hashed, so a long/immutable cache would keep
|
|
# serving a stale bundle after every deploy. Force revalidation instead:
|
|
# cheap 304s when unchanged, immediate pickup of new content when not.
|
|
location /umd/ {
|
|
add_header Cache-Control "no-cache";
|
|
}
|
|
|
|
location /img/ {
|
|
add_header Cache-Control "public, max-age=86400";
|
|
}
|
|
}
|