前言
- 白屏问题很多种,这里只针对线上版本(网页端)更新后,微信小程序打开白屏问题
-
白屏原因:微信浏览器缓存了html等文件,导致更新后无法加载
image.png
-
当前版本解决,只能在系统中,清空微信的缓存(不是所有缓存)
或者等几小时或者2天自动失效,可以试试推新版本(未测试)
解决方案(该解决方案,只能针对下一次版本更新)
-
解决方案是服务器nginx解决。
-
在服务器中,给入口html页面的访问添加响应头,如在nginx中配置 Cache-Control 为 no-store, no-cache。这样浏览器访问页面时,就不会缓存该页面。
-
原理很简单,就是禁止html被缓存。
-
nginx代码
# 配置页面不缓存html和htm结尾的文件
location / {
...
if ($request_filename ~* .*\.(?:htm|html)$)
{
add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
}
...
}

网友评论