2026-04-29-nrc4 #1
18
nginx.conf
18
nginx.conf
@@ -1,8 +1,3 @@
|
||||
# 前端静态站点:发版后让用户尽快拿到新版本
|
||||
# — index.html 禁止缓存(每次拉最新入口,里面的 script/link 会指向新的 hash 资源)
|
||||
# — /static/ 下 Webpack 带 chunkhash/contenthash 的文件可长期缓存(文件名变 = 新文件)
|
||||
# 仍需每次发版:重新 build、把新 dist 部署到本 root(或重建/更新镜像并重启容器)
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
@@ -10,19 +5,6 @@ server {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
# 入口页:不缓存,避免一直用旧的 index 引用旧 js/css
|
||||
location = /index.html {
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0" always;
|
||||
add_header Pragma "no-cache" always;
|
||||
}
|
||||
|
||||
# Webpack 产物:文件名含 hash,可安全长期缓存
|
||||
location ^~ /static/ {
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable" always;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location /it/api/ {
|
||||
proxy_pass http://172.18.0.1:5010;
|
||||
proxy_set_header Host $host;
|
||||
|
||||
Reference in New Issue
Block a user