简体   繁体   English

如何使用angularjs或javascript清除浏览器缓存?

[英]how to clear browser cache using angularjs or javascript?

I developed the application with angularjs and C program. 我用angularjs和C程序开发了应用程序。 When API with C program change the data, view should be change. 当带有C程序的API更改数据时,应该更改视图。 But after refreshing the page also new data is not updating in view. 但刷新页面后,新数据也未在视图中更新。

When I am clearing browser's cache manually, my new data is getting updated in view. 当我手动清除浏览器的缓存时,我的新数据将在视图中更新。 So the problem is with cache only. 所以问题只在于缓存。

In solution for this issue, I have added following HTML tags. 在针对此问题的解决方案中,我添加了以下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" />

These is working, but sometimes it fails, and again catching the cache data. 这些工作正常,但有时会失败,并再次捕获缓存数据。

So please know, if is there any another solution using AngularJS or JavaScript? 所以请知道,如果有任何其他解决方案使用AngularJS或JavaScript?

Thanks in advance! 提前致谢!

The browser will respect the cache time set by the response for that particular asset. 浏览器将遵循该特定资产的响应设置的缓存时间。 Any subsequent GET should look to the cache until the timeout is reached. 任何后续GET都应该查看缓存,直到达到超时。

Its possible you have click here ignoring this. 你有可能点击这里忽略这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM