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 小时前
Vue 不同大版本与 Node.js 版本匹配的详细参数
前端·vue.js·node.js
尚学教辅学习资料4 小时前
基于SpringBoot+vue+uniapp的智慧旅游小程序+LW示例参考
vue.js·spring boot·uni-app·旅游
IT、木易4 小时前
跟着AI学vue第五章
前端·javascript·vue.js
guihong0044 小时前
Redis 深度解析:高性能缓存与分布式数据存储的核心利器
redis·分布式·缓存
薛定谔的猫-菜鸟程序员4 小时前
Vue 2全屏滚动动画实战:结合fullpage-vue与animate.css打造炫酷H5页面
前端·css·vue.js
春天姐姐5 小时前
vue3项目开发总结
前端·vue.js·git
qq_529835357 小时前
Redis作为缓存和数据库的数据一致性问题
数据库·redis·缓存
烂蜻蜓8 小时前
前端已死?什么是前端
开发语言·前端·javascript·vue.js·uni-app
谢尔登10 小时前
Vue 和 React 的异同点
前端·vue.js·react.js
艾斯比的日常13 小时前
提升接口性能之缓存
缓存