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
---