异常描述:
支付宝中内嵌h5项目(开发),前端重新打包上传之后访问页面会导致页面空白、页面tab点击异常之类异常情况,需要手动清除支付宝缓存才可以正常访问。
解决方案:
在HTTP协议中,只有后端返回 expires 或 Cache-Control:max-age=XXX, 前端才缓存。
但在浏览器中,默认会对 缓存,如果在HEAD头中指定:
浏览器不会
我的最终解决方案是:
1) 对hash过的静态文件还是采用默认方式,客户端会
2)对html文件,返回时增加头:Cache-Control,必须每次来服务端校验,根据etag返回200或者304
对应的nginx配置如下:
upstream example-be {
ip_hash;
server unix:/run/example-be.sock;
}
server{
listen 80; #监听端口
server_name example.com
# 后台api
location ~ ^/api {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
include uwsgi_params;
uwsgi_pass example-be;
}
# 前端静态文件
location ~* \.(gif|jpg|jpeg|png|
由于浏览器
# 前端静态文件
location ~* \.(gif|jpg|jpeg|png|
以上这篇