缓存清除如何在index.html 上工作?

wed*_*rer 4 caching http

缓存溢出的主要两种方法是:

  1. 文件名内的哈希值:styles.hash123.css
  2. 路径内的哈希值:styles.css?v=version1.23

我了解这背后的原因和机制。

然而我不明白的是如何缓存网站的index.html,例如SPA。浏览器缓存可以长时间保留 SPA 的 index.html,因此 css/js 文件永远不会被缓存破坏。

浏览器是否将 index.html 作为特殊情况处理,或者是否会发生所描述的行为?

nem*_*emo 5

添加到您的 HTML 头部:

<meta http-equiv="Cache-Control" content="max-age=0, must-revalidate"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Expires" content="0" />
Run Code Online (Sandbox Code Playgroud)