ExtJs 应用程序缓存警告 [英] ExtJs Application Cache warning
问题描述
我有一个用 ExtJs 编写的单页应用程序.我没有使用应用程序缓存,但是当应用程序启动时,我在 Chrome 中看到以下警告:
I have a single page app written with ExtJs. I'm not using the application cache but when the app launches I see the following warning in Chrome:
[弃用] 应用缓存 API 已弃用,将于 2020 年 4 月左右在 M82 中移除.请参阅 https://www.chromestatus.com/features/6192449487634432 了解更多详情.
[Deprecation] Application Cache API use is deprecated and will be removed in M82, around April 2020. See https://www.chromestatus.com/features/6192449487634432 for more details.
此问题已在 Sencha 论坛上多次发布 (此处 和 此处) 返回几个年.唯一的回应来自一个非煎茶海报说它应该没问题".不完全是您希望的答案.
This question has been posted multiple times on the Sencha forums (here and here) going back several years. The only response has been from a non-Sencha poster saying it "should be ok." Not exactly the answer you would hope for.
有谁知道如何摆脱这个警告?考虑到我没有明确使用应用程序缓存,听起来好像 ExtJs 可能在后台用它做一些事情.这就是我所关心的.
Does anyone have any idea how to get rid of this warning? Considering I am not explicitly using the application cache it sounds as if ExtJs might be doing something with it in the background. That is what concerns me.
推荐答案
我决定调查这个问题,因为我发现这个问题很有趣.
I decided to investigate this problem because I found the question interesting.
简短的回答是,除非您明确使用 applicationCache
,否则它真的不会以任何方式影响您的应用程序.
The short answer is that it really will not affect your application in any way unless you explicitly use applicationCache
.
详情:
即使您只是尝试调用 window.applicationCache
属性,也会出现警告
A warning appears even if you simply try to call the window.applicationCache
property
applicationCache
有什么用?它缓存静态文件(js 和 css)以使您的应用程序脱机工作.该技术已被 ServiceWorker 取代.使用 applicationCache 缓存的工作原理如下(简短说明,完整的 MDN):
What is applicationCache
used for? It caches static files (js and css) to make your application work offline. This technology has been replaced by ServiceWorker's. Caching using applicationCache works as follows (short description, full on MDN):
- 您创建了一个专门编写的清单...
- 并在页面上
html
标签的manifest
属性中设置它的路径 - 之后,该清单中的文件将保存在 applicationCache 中
- You create a specially composed manifest ...
- and set path to it in
manifest
attribute of thehtml
tag on your page - after that the files from that manifest will be saved in applicationCache
在 Sencha 应用程序中,这显示为脚本 https://docs.sencha.com/extjs/6.2.0/classic/src/Microloader.js.html 其中注入到您的页面中.
In the Sencha application, this appears as a result of the script https://docs.sencha.com/extjs/6.2.0/classic/src/Microloader.js.html which injected into your page.
在这个文件中,一个在 applicationCache 上构建的包装器和创建侦听器被分配给 applicationCache
.这些侦听器的处理程序更改包装器内的状态并调用 notifyUpdateReady
方法,该方法又调用全局 appupdate
事件.同时,所有这些代码都是抽象的,对applicationCache的整体运行几乎没有影响.
In this file, a built wrapper over applicationCache and create listeners are assigned to the applicationCache
. The handlers of these listeners change the status inside the wrapper and call the notifyUpdateReady
method, which in turn calls the global appupdate
event.
At the same time, all this code is abstract and has almost no effect on the overall operation of applicationCache.
如果有疑问,您可以模拟禁用 applicationCache.在 if (_cache){...
之前在 checkAllUpdates
方法中设置调试器并覆盖 _cache (_cache = undefined;
).然后将控制权返回给浏览器.什么都不会发生.
If in doubt, you can simulate disabling applicationCache. Set the debugger in checkAllUpdates
method before if (_cache){...
and override _cache (_cache = undefined;
). Then return control to the browser. Nothing will happen.
我使用 SenchaFiddle 示例测试了所有这些.那里根本没有使用缓存.它没有清单
I tested all this using the SenchaFiddle example. Cache is not used there at all. It dosen't have manifest
我重复一下结论 - 如果您没有明确使用 applicationCache - 您无需担心.您可以通过查看页面代码和查找清单连接来检查它是否被您使用.也可以在控制台执行以下代码
I repeat the conclusion - if you are not using applicationCache explicitly - you have nothing to worry about. You can check whether it is used by you by looking at the page code and looking for the manifest connection. You can also execute the following code in the console
window.applicationCache.status
如果结果为 0,则缓存未在您的应用程序中初始化
if the result is 0, the cache was not initialized in your application
这篇关于ExtJs 应用程序缓存警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!