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)

相关推荐
spmcor2 天前
身份证读卡“无感登录”方案实践:从手动点击到自动检测
uni-app
PedroQue992 天前
uni-router v1.8.0新增冷启动守卫补执行
前端·uni-app
PedroQue993 天前
uni-router v1.7.0重磅更新:守卫重定向自由掌控
前端·uni-app
小七-七牛开发者5 天前
TokenPilot:让 LLM Agent 长会话成本降 60%+ 的上下文管理
缓存·agent·token·context·上下文·推理成本
一份执念5 天前
uni-app项目 (vue+vite + uni-UI)中引入umd格式JS文件,微信小程序中导入报错处理方案
前端·uni-app·echarts
PedroQue995 天前
V1.6.1性能优化:高频路径提速与代码精简
前端·uni-app
夏碧笔7 天前
uni-app跨端地图实战:用第三方LBS替代微信平台收费服务
uni-app
用户69903048487512 天前
try catch使用场景 处理同步代码错误兼容用的
javascript·uni-app
ITKEY_12 天前
uniapp微信开发者工具 更改AppID失败 touristappid
uni-app
ofoxcoding12 天前
在AI API聚合平台配置DeepSeek V3.2提示词缓存实战:快速接入与成本优化指南
人工智能·spring·缓存·ai