单页面nginx/openresty部署,去除Html缓存问题(设置客户端不缓存):
server {
listen 80;
server_name xxxx.com;
# etag off; # 负载均衡情况下关闭
underscores_in_headers on;
location / {
if ($request_filename ~ .*\.(htm|html)$) {
expires -1s;
add_header Cache-Control no-cache;
}
root /home/xxx/dist;
try_files $uri $uri/ = /index.html;
index index.html;
}
location ^~/api/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Host $host;
# 后台API对接地址
proxy_pass http://127.0.0.1:0000/api/;
}
}
博客迁移新地址:点击前往
大前端知识库收集分享 www.190tech.site 壹玖零Tech
搜罗各种前后端奇淫技巧,花式编程思想,日日更新,速来围观吧...