[feat]增加nginx不缓存index.html配置,搭配前端版本自动升级功能使用(不加此配置可能会导致用户刷新后还是旧版本)
This commit is contained in:
@@ -7,6 +7,10 @@ server {
|
|||||||
index index.html index.htm;
|
index index.html index.htm;
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
try_files $uri $uri/ /index.html;
|
try_files $uri $uri/ /index.html;
|
||||||
|
# 禁止缓存html文件,避免前端页面不及时更新,需要用户手动刷新的情况
|
||||||
|
if ($request_uri ~* "^/$|^/index.html|^/index.htm") {
|
||||||
|
add_header Cache-Control "no-store";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
location ~ ^/api/ {
|
location ~ ^/api/ {
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ server {
|
|||||||
real_ip_header X-Forwarded-For;
|
real_ip_header X-Forwarded-For;
|
||||||
root /usr/share/nginx/html;
|
root /usr/share/nginx/html;
|
||||||
index index.html index.php index.htm;
|
index index.html index.php index.htm;
|
||||||
|
# 禁止缓存html文件,避免前端页面不及时更新,需要用户手动刷新的情况
|
||||||
|
if ($request_uri ~* "^/$|^/index.html|^/index.htm") {
|
||||||
|
add_header Cache-Control "no-store";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
location /api/ {
|
location /api/ {
|
||||||
|
|||||||
Reference in New Issue
Block a user