我正在尝试使用我的 ServiceWorker(使用 sw-toolbox.js)缓存 iframe 的请求。
但是,无论我尝试什么,都不会像 Chrome Network Tab 告诉我的那样从 ServiceWorker 提供文件。
这是我的 service-worker.js:
'use strict';
importScripts('./build/sw-toolbox.js');
self.toolbox.options.cache = {
name: 'ionic-cache'
};
var static_urls = [
'https://quiqqer.local/test?app=1',
'https://quiqqer.local/calendar?app=1'
];
self.toolbox.precache(static_urls);
self.toolbox.router.any('/(.*)', self.toolbox.cacheFirst, {origin: 'https://quiqqer.local'});
self.addEventListener('install', function (event)
{
self.skipWaiting();
});
self.toolbox.router.default = self.toolbox.cacheFirst;
Run Code Online (Sandbox Code Playgroud)
self.toolbox.precache() 函数正确地向我的 static_url 发出请求,正如我在网络选项卡中看到的那样。
但是来自 iframe 的所有请求(转到https://quiqqer.local/)似乎都没有通过 ServiceWorker 路由。
我究竟做错了什么?或者不能缓存 iframe 请求?
使用 Linux 在 Chromium 上运行。
提前致谢