diff --git a/docker/nginx.common.conf b/docker/nginx.common.conf index 528bd4c1..21d70611 100644 --- a/docker/nginx.common.conf +++ b/docker/nginx.common.conf @@ -76,6 +76,20 @@ location ~* \.(png|jpg|jpeg|gif|ico|svg)$ { add_header Cache-Control "public, immutable"; } +# Service Worker 和 Web App Manifest 需要稳定 URL 但不能长缓存,否则前端更新时浏览器可能继续注册旧版本。 +location = /service-worker.js { + expires off; + add_header Cache-Control "no-cache, must-revalidate"; + try_files $uri =404; +} + +location = /manifest.webmanifest { + expires off; + default_type application/manifest+json; + add_header Cache-Control "no-cache, must-revalidate"; + try_files $uri =404; +} + # JS 和 CSS 静态资源缓存(排除 /api/v1 路径) location ~* ^/(?!api/v1).*\.(js|css)$ { try_files $uri =404; @@ -86,8 +100,7 @@ location ~* ^/(?!api/v1).*\.(js|css)$ { # assets目录 location /assets { - expires 1y; - add_header Cache-Control "public, immutable"; + add_header Cache-Control "public, max-age=31536000, immutable"; } # 站点图标