react 移动端公众号项目清除微信缓存

作者: IFu的简书 | 来源:发表于2020-03-26 22:28 被阅读0次

问题描述:

    最近在给甲方爸爸做一个公众号的移动端项目,每周都会去服务器更新新的功能。但是由于微信自带的缓存功能,导致服务器重启后,还是原来的页面。每次都让甲方爸爸清除缓存,体验总归是不太好的嘛~~~

缓存问题,没有什么彻底的解决方案,只能尽力优化。

解决方案:

1,入口文件index.html  meta优化                                                            ☆ 一般

<meta http-equiv="Expires" content="0">

<meta http-equiv="Pragma" content="no-cache">

<meta http-equiv="Cache-control" content="no-cache">

<meta http-equiv="Cache" content="no-cache">

2、打包的时候加版本号 或者时间戳,目的区分路径                           ☆☆☆ 最优

//在webpack.config.js文件中进行配置

2.1  webpack.config.js 时间戳 2.2  output打包完文件名字多了时间戳

3、在nginx 中,把入口文件,缓存给清了                                            ☆☆一般

// nginx端配置

location = /index.html {

    add_header Cache-Control "no-cache, no-store";

    # add_header Cache-Control no-store;

    # add_header Pragma no-cache;

}

    expires 期限 可以用于设定网页的到期时间。一旦网页过期,必须到服务器上重新传输。

    expires 30s;

    add_header Cache-Control no-store;

4、通过在url的链接上加入时间戳或者版本号,当请求同一页面,如果url后的参数不同,就会重新调取页面。(没有尝试)

相关文章

网友评论

    本文标题:react 移动端公众号项目清除微信缓存

    本文链接:https://www.haomeiwen.com/subject/bgyquhtx.html