這是我第一次使用服務人員緩存某些內容的交互。正如我的POC我試圖緩存的資產,如「JS」,「CSS」,服務人員緩存需要時間來響應延遲
的一部分,我使用sw-toolbox
(function (global) {
'use strict';
// Ensure that our service worker takes control of the page as soon as possible.
global.addEventListener('install', function (event) {
return event.waitUntil(global.skipWaiting());
});
global.addEventListener('activate', function (event) {
return event.waitUntil(global.clients.claim());
});
// The route for any requests from the googleapis origin
toolbox.router.get('/(.*)', global.toolbox.cacheFirst, {
cache: {
name: 'modjs',
maxEntries: 30,
maxAgeSeconds: 86400
},
debug: true,
origin: /\.abc\.com\:8044$/
});
})(self);
讓我怎麼了?
此外,你可以再次嘗試不帶'緩存:{}'選項,這些選項用於設置緩存過期?它們應該以一種使其不在頁面返回響應關鍵路徑之外的方式實現,但這是一回事。 –