AngularJS 浏览器缓存问题 [英] AngularJS browser cache issues
问题描述
早上好,我在生产环境中有一个 Web 应用程序.用户每天都在使用它,当我发布更新并且用户返回 Web 应用程序时,他会查看 Web 应用程序的旧版本.他需要刷新浏览器以加载新版本.我怎么解决这个问题?每次我发布更新(每周 3-4 次)时,我都无法告诉数百名用户刷新页面.
Good morning, I have a web application in production environement. The users are using it every day, when I publish an update and a user comes back to the web application he views the old version of the web application. He needs to refresh the browser to load the new version. How can I solve this problem? I cannot tell hundreds of users to refresh the page every time I publish an update (3-4 times a week).
推荐答案
一个简单的解决方案是将表示时间戳或会话 ID 的查询字符串添加到您的文件中.
A simple solution would be to add query strings representing timestamp or session id to your files.
例如,在我们的 spring 应用程序中,我们只需使用:
For e.g., in our spring applications, we simply use :
<script src="js/angular/lib/app.js?r=<%= session.getId()%>"></script>
您也可以在特定于服务器的实现中实现相同的解决方案.
You can implement the same solution in your server specific implementation too.
这篇关于AngularJS 浏览器缓存问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!