解决的问题: 要防止网站根路径被缓存并返回304状态码
server {
listen 443 ssl;
...
# 根路径的location块
location = / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
root www;
index index.html index.htm;
try_files $uri $uri/ /index.html last;
# 禁止缓存以及304响应
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
}
本文介绍了如何在Nginx服务器配置中防止网站根路径被浏览器缓存,并确保始终从服务器获取最新内容,通过设置适当的HTTP头和代理规则来实现。
1万+

被折叠的 条评论
为什么被折叠?



