【问题标题】:how to clear browser cache using angularjs or javascript?如何使用 angularjs 或 javascript 清除浏览器缓存?
【发布时间】:2016-06-28 11:28:20
【问题描述】:

我用 angularjs 和 C 程序开发了这个应用程序。当API用C程序改变数据时,视图应该改变。但是刷新页面后,新数据也没有在视图中更新。

当我手动清除浏览器的缓存时,我的新数据会在视图中更新。所以问题只出在缓存上。

在此问题的解决方案中,我添加了以下 HTML 标记。

        <meta http-equiv="cache-control" content="max-age=0" />
        <meta http-equiv="cache-control" content="no-cache" />
        <meta http-equiv="cache-control" content="no-store" />
        <meta http-equiv="expires" content="0" />
        <meta http-equiv="expires" content="-1" />
        <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
        <meta http-equiv="pragma" content="no-cache" />

这些工作正常,但有时会失败,并再次捕获缓存数据。

所以请知道,是否还有其他使用 AngularJS 或 JavaScript 的解决方案?

提前致谢!

【问题讨论】:

标签: javascript angularjs html browser-cache


【解决方案1】:

浏览器将遵守该特定资产的响应设置的缓存时间。任何后续 GET 都应查看缓存,直到达到超时。

你有可能click here 忽略了这一点。

【讨论】:

  • 我会这样做,但是客户会怎么做!
猜你喜欢
  • 2017-04-06
  • 2019-01-18
  • 2018-07-27
  • 1970-01-01
  • 2017-07-20
  • 1970-01-01
  • 2015-10-29
  • 2010-11-05
  • 2017-12-08
相关资源
最近更新 更多