I use Workbox to pre-cache assets required to render the app shell, including a basic version of index.html
. Workbox assumes that index.html
is available in cache, otherwise, page navigation fails because I have this registered in my Service Worker:
workbox.routing.registerNavigationRoute('/index.html');
I also have the self.skipWaiting()
instruction in the install listener:
self.addEventListener('install', e => {
self.skipWaiting();
});
As I understand it, there are 2 install
listeners now:
- One that's registered by Workbox for pre-caching assets (including index.html)
- One that I registered manually in my Service Worker
Is it possible for self.skipWaiting()
to succeed while Workbox's install listener fails? This would lead to a problematic state where assets don't get pre-cached but the Service Worker is activated. Is such a scenario possible and should I protect against it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…