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)

相关推荐
JavaDog程序狗7 小时前
【指南】uni-app微信小程序多环境CI-CD完全指南
ci/cd·uni-app·jenkins
PedroQue998 小时前
uni-router v2.1.0 升级:导航守卫全面支持返回值模式
前端·uni-app
野生技术架构师8 小时前
Redis 和 MySQL 如何保证数据一致性?先更新数据库还是先删缓存,延迟双删、MQ、Canal 一次讲透
数据库·redis·缓存
愈努力俞幸运9 小时前
token,context window,top_p,temperature,skill,Harness Engineering
数据库·redis·缓存
Patrick在香港9 小时前
Claude API 成本直降90%:Prompt Caching 提示词缓存 Python 实战
python·缓存·prompt
NeilYuen1 天前
【vemory】高性能KV存储AOF方案设计
linux·c++·redis·缓存
2501_915909061 天前
iOS test 测试怎么做?功能、性能、兼容、稳定与安全五类测试指南
android·ios·小程序·https·uni-app·iphone·webview
LuminousCPP1 天前
数据结构基础篇(二):顺序表与链表全方位对比|从内存布局到 CPU 缓存理解底层差异
c语言·数据结构·经验分享·链表·缓存
spter。1 天前
Redis 与 Single-flight 的分工与协作
数据库·redis·缓存
清水白石0081 天前
Python 如何设计一个线程安全的缓存?从锁策略、LRU 到工程化实战
python·安全·缓存