- From: Jake Archibald <notifications@github.com>
- Date: Wed, 29 Jun 2016 08:20:43 -0700
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc:
Received on Wednesday, 29 June 2016 15:21:11 UTC
With the routing proposal... ```js self.addEventListener('install', event => { event.waitUntil( // populate caches ); }); self.addEventListener('fetch', event => { event.respondWith( caches.match(event.request).then(r => r || fetch(event.request)) ); }); ``` ...could be replaced with.... ```js self.addEventListener('install', event => { event.waitUntil( // populate caches ); event.declareRoute("/", new FallbackSources( new CachesSource(), new FetchSource() )); }); ``` ...and the SW wouldn't need to boot up for any fetch events. My blog currently composes a streamed response. If the cost of service worker bootup was greater than its benefit, I could do: ```js self.addEventListener('install', event => { event.waitUntil( // populate caches ); event.declareRoute({mode: "navigation"}, new AnySource( new FetchEventSource(), new FetchSource() )); }); ``` ...allowing the browser to race the network and the fetch event for navigations. --- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/slightlyoff/ServiceWorker/issues/920#issuecomment-229390344
Received on Wednesday, 29 June 2016 15:21:11 UTC