【问题标题】:Angular caching index.html for one specific url一个特定网址的角度缓存 index.html
【发布时间】:2020-09-10 05:22:40
【问题描述】:

这是它所能得到的最奇怪的。我使用所有新的散列 js 文件重新部署了我的 Angular 应用程序。

期望从服务器获取新文件,包括 html、css、js。

除了从缓存切换回旧版本 index.html 然后从缓存中提取旧 js 文件的 url 之外,它工作正常。

我一直在尝试解决此问题,但找不到任何解决方案。

我已经在html文件中添加了这些文件

    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Expires" content="0">

这在 web.config 中

<customHeaders>
    <add name="Cache-Control" value="no-cache, no-store, must-revalidate, pre-check=0, post-check=0, max-age=0, s-maxage=0" />
    <add name="Pragma" value="no-cache" />
    <add name="Expires" value="0" />
  </customHeaders>

但这些更改没有影响。

【问题讨论】:

  • 你能更详细地描述缓存哪个 url 吗?
  • 你说的是获取某个api的url?提供更多细节。
  • 它的 Angular url,而不是 api。,有一个路径,当我路由时,它会被缓存 index.html
  • stackblitz好吗?
  • 它的缓存问题,我如何在stackblitz中重现它!

标签: iis http-caching


【解决方案1】:

缓存问题与服务器有关,而不是从角度。请查看您在任何请求中收到的服务器配置和标头,您可以尝试在服务器配置文件中进行相应更改,直到问题解决。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-12-13
    • 2014-11-03
    • 1970-01-01
    • 2013-05-06
    • 1970-01-01
    • 1970-01-01
    • 2023-03-09
    相关资源
    最近更新 更多