方案一:在页面中添加meta标签。
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" /> //设置页面过期时间
<meta http-equiv="pragma" content="no-cache" /> //
复制代码
方案二:JS监听pagehide/pageshow来阻止页面进入bfcache/page cache,或者监测到页面从bfcache/page cache中加载展现时进行刷新。参考: Forcing mobile Safari to re-evaluate the cached page when user presses back button。
示例代码:
window.onpageshow = function(event) {
if (event.persisted) {
window.location.reload()
}
};
复制代码