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
---
相关推荐
jktantan7 小时前
Vue keep-alive 切标签后滚动位置回顶?因为 onDeactivated 里读到的 scrollTop 是 0
前端·javascript·vue.js
小郎君65816 小时前
(一)为什么表单需要第三种状态:disabled、readonly 与纯文本展示
前端·vue.js
莫晓燚16 小时前
搭建Redis 主从复制---实战
数据库·redis·缓存
李纲明18 小时前
微信小程序真机预览白屏或 request 失败:先核 request 合法域名与 TLS,再查体验版与本地缓存
缓存·微信小程序·小程序·小程序开发·devdiy·真机预览·合法域名
jktantan18 小时前
(二)Vue 3 的 attrs 不是响应式:el-form 扩展属性同步的三种方案
前端·javascript·vue.js·element-plus
雾时之林20 小时前
Nginx反向代理与proxy_cache缓存搭建CDN服务器
服务器·nginx·缓存
鬼手点金21 小时前
提示注入:上下文安全的核心威胁
人工智能·安全·microsoft·机器学习·缓存·prompt
是程序喵呀21 小时前
Redis实现持久化
数据库·redis·缓存
Highcharts.js21 小时前
Highcharts 集成到 React 或 Vue 项目中时,如何高效地使用 TypeScript技巧?
vue.js·人工智能·react.js·typescript·前端框架·highcharts
Java后端的Ai之路1 天前
CAS并发控制-从CPU指令到企业级乐观锁
vue.js·人工智能·python·cas·乐观锁