简体   繁体   English

在OpenUI5中强制清除缓存

[英]Force clear cache in OpenUI5

I have created an OpenUI5 app and I want to relase a new version daily. 我已经创建了一个OpenUI5应用,我想每天发布一个新版本。 But I found some problems: 但是我发现了一些问题:

  1. Not always on the client browser is loaded the last version of javascript (I have a label that show the version and to see the last number is requred a manual refresh by F5) 并非总是在客户端浏览器上加载javascript的最新版本(我有一个标签来显示该版本,并看到最后一个数字需要F5手动刷新)
  2. I have a JSon file that i use to bind a menu. 我有一个用于绑定菜单的JSon文件。 If I modify it, on the client browser it remains in cache and also with F5 not load the new version. 如果我对其进行了修改,则它在客户端浏览器上仍保留在缓存中,并且在F5中不会加载新版本。 The solution is clear data of browser (...) 解决方案是清除浏览器的数据(...)

Now I have this meta-tags on my index page: 现在,我在索引页面上有了这个元标记:

<meta http-equiv="expires" content="0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />

Is there a way to force the reload of all content always? 有没有办法始终强制重新加载所有内容? (or when I modify the version number?) (或者当我修改版本号时?)

This really depends on what server you are using to serve the content and whether you can set the headers when it serves the various JS files to the client. 这实际上取决于您使用哪台服务器提供内容,以及当它向客户端提供各种JS文件时是否可以设置标头。 Unfortunately this is probably just disabling the cache all the time. 不幸的是,这可能只是一直禁用缓存。

There is also a built in concept called "Cache-buster" which is documented here - OpenUI5 Cache Buster . 还有一个称为“ Cache-buster”的内置概念,在此处记录-OpenUI5 Cache Buster This does something clever and puts a timestamp or version number in the url which is read from a config file. 这做得很聪明,并将时间戳或版本号放在从配置文件读取的url中。 If you are hosting on an ABAP stack then this is built in for you and easy to enable, if you aren't it's still easy to manually implement. 如果您托管在ABAP堆栈上,那么它将为您内置并且易于启用;如果不是,则手动实现仍然很容易。

I have solved my problem using ONLY 我仅使用即可解决问题

 <meta http-equiv="cache-control" content="no-cache" />

as show in this post: 如这篇文章中所示:

https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching

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

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