- From: Salvador de la Puente González <notifications@github.com>
- Date: Tue, 26 Jul 2016 11:15:55 -0700
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
- Message-ID: <slightlyoff/ServiceWorker/issues/920/235357063@github.com>
Aside from Facebook problem. Although @jakearchibald declarative syntax is tempting, I think it is too soon for this. @slightlyoff preflight solution seems to me a very valid options but I really think it should be opt-in so, during registration, a service worker could include a preflight list (`networkRace`) such as: ```js navigator.serviceWorker.register('sw.js', { scope: '/', networkRace: ['/ping', '/shell-assets'] }); ``` List items would act as prefixes so any request to `/shell-assets/*` would be raced with the service worker. About the problem with the 3 GiB video, you could cancel the response in progress (I'm not talking about _cancellable_ promises) by modifying the API: ```js self.onfetch = (e) => { if (isHeavyAsset(e.request) && e.networkResponse.inProgress) { e.networkResponse.abort(); e.respondWith(handle(e.request)); } } ``` If for some race condition, you end sending another request to the network as in: ```js self.onfetch = event => { event.respondWith( event.preflightResponse || fetch(event.request) ) } ``` The second one will hit the http cache hopefully instead of reaching the actual network. Does it make sense? --- 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-235357063
Received on Tuesday, 26 July 2016 18:16:30 UTC