在部署后,Angular应用程序无法正常工作,直到我们从浏览器清除缓存
我们有一个在前端中使用角度的应用。每当我们进行部署时,在清除浏览器中的完整缓存之前,某些功能都无法正常工作。我们知道这是由于缓存而发生的。有什么方法可以解决此问题?我们需要在部署后重新加载页面后立即起作用。尤其是在Mac中,我们经常面临问题,因为它们不会关闭其系统&关闭浏览器。
任何帮助将不胜感激。
更新1: Angular在每个构建中生成不同哈希的文件,但我们仍然面临此问题。
另外,我们尝试在index.html中添加这些代码。但是没有任何帮助我们解决这个问题。
<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">
We have an application where angular is used in the frontend. Whenever we do the deployments, some of the functionalities are not working properly until we clear the complete cache in the browser. We knew it this is happening due to cache. Is there any way to fix this issue? We need as soon as they reload the page after the deployment, it should work. Especially in MAC, we are facing the issue frequently as they do not switch off their system & close the browser.
Any help would be appreciated.
Update 1:
Angular generates the files with different hash on every build, but still we face this issue.
Also we tried adding these codes in index.html. But nothing helped us to resolve this issue.
<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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从事大项目(与3人一起发展3年)。
我们使用GULP修复了什么(用于准备prod时使用时间戳的准备设备设置,并使用当前实际的version.json文件)。
因此,在每5分钟的生产中,前面尝试上传文件,并使用当前的前版本检查Curreant Real版本,以及当前的Front +new Date()&lt; +new Date()(来自version.json)我们向用户显示对话框“我们有新的真实!并致电页面刷新。刷新后版本将与版本相同。
I was working under big project (3 years of develop from with 3 people).
We fixed what with using gulp (for prepare env file setting with timestamp when prod was prepared and version.json file with current actual).
So in production each 5 minutes front try to upload file and check curreant real version with current front version and if current front +new Date() < +new Date() (from version.json) we show dialog to user "we have new realse! Do u want reload page now or u will do it leater?" and call page refresh. After refresh front version will be same with version.json