uniapp使用webView打开的网页有缓存如何解决(APP,微信小程序)

1、给webView的url增加时间戳

复制代码
this.webviewUrl = `${url}?t=${new Date().getTime()}`; // 添加时间戳

2、在nginx服务器上添加响应头,告诉浏览器不可以使用缓存

复制代码
location / {
    root  /opt/webs/lcdp-client/dist;
    index index.html index.htm;
    try_files  $uri $uri/ /index.html;  #解决刷新变404问题900

    # 添加 Cache-Control 头
    add_header Cache-Control "no-store, no-cache, must-revalidate";
    add_header Pragma "no-cache";
    expires -1;
}

可以参考微信小程序web-view缓存问题及解决方案微信小程序中的web-view嵌入了h5的页面,h5页面更新重新发版后,we - 掘金 (juejin.cn)

相关推荐
桌面运维家15 小时前
如何用半缓存云桌面将服务器硬盘容量扩展至本地终端?
运维·服务器·缓存
YOU OU20 小时前
Redis初识
数据库·redis·缓存
livemetee1 天前
【关于redis高性能,高可用处理】
数据库·redis·缓存
青山木1 天前
Hot 100 --- LRU 缓存
java·数据结构·算法·leetcode·链表·缓存·哈希
无小道1 天前
Redis——哨兵
数据库·redis·缓存·哨兵
闪电悠米1 天前
黑马点评-Redis Set-实现关注、取关和共同关注
数据库·redis·缓存
天丁o1 天前
Spring Boot + uni-app 智慧考勤闭环 Demo:打卡记录、异常状态和日统计如何复用到企业系统
spring boot·uni-app·mybatis plus·企业管理系统·考勤系统
Ricky_Theseus1 天前
CrewAI 生产化:缓存、回调、LLM 配置
java·spring·缓存
这是个栗子1 天前
uni-app 微信小程序开发:常用事件指令(@xxx)(一)
微信小程序·小程序·uni-app
风向决定发型丶1 天前
redis集群搭建
数据库·redis·缓存