vuepress 浏览器加载缓存,总是显示旧页面,无法自动刷新数据的解决方法

vuepress 采用多页面形式,每个md文件在打包时,都会被转为一个html页面;而浏览器默认会缓存页面,导致更新的页面必须手动刷新才行

对于更新较为频繁的文档

  • 全局可在config.js里设置

参考文档:

https://vuepress.github.io/zh/reference/config.html#head

https://vuepress.github.io/zh/reference/frontmatter.html#description

js 复制代码
export default defineUserConfig({
  ...
  head: [
    ["meta", {"http-equiv": "Pragma", content: "no-cache"}],
    ["meta", {"http-equiv": "Cache-Control", content: "no-cache"}],
    ["meta", {"http-equiv": "Expires", content: "0"}]
  ],
})
  • 单页面可以按Frontmatter语法要求在相应md文件设置
md 复制代码
---
head:
  - - meta
    - http-equiv: Pragma
      content: no-cache
    - http-equiv: Cache-Control
       content: no-cache
    - http-equiv: Expires
       content: 0
---
相关推荐
高级程序源3 小时前
django校园寻物通失物招领平台32261-计算机课程设计、毕业设计
vue.js·python·mysql·小程序·django·flask·课程设计
WeiXin_DZbishe4 小时前
基于springboot宠物领养系统-计算机毕设 附源码【课程设计】94217
vue.js·spring boot·python·django·php·课程设计
WeiXin_DZbishe6 小时前
基于springboot城市公交实时运营与调度系统-计算机毕设 附源码【课程设计】66173
java·vue.js·spring boot·后端·python·php·课程设计
WeiXin_DZbishe6 小时前
基于Springboot+AI的kuall音乐广场的设计与实现-计算机毕设 附源码【课程设计】12715
vue.js·人工智能·spring boot·后端·python·php·课程设计
_馒头7 小时前
pixiJs游戏开发实践 - 跳棋小游戏
javascript·vue.js
AIGC小尼8 小时前
毕设实战|SpringBoot+Vue 实现多个系统项目
vue.js·spring boot·课程设计
蓝胖的四次元口袋10 小时前
Redis知识梳理(1)
数据库·redis·缓存
wefg110 小时前
【Redis】C++ 自定义客户端
数据库·redis·缓存
踩着两条虫11 小时前
我在浏览器里“盖”了一个村:Vue + Three.js 大屏开发踩坑记
前端·vue.js·three.js
高级程序源13 小时前
SSM仓储管理系统31582-计算机课程设计、毕业设计
vue.js·python·mysql·小程序·flask·课程设计