Re: [w3c/ServiceWorker] Making a concurrent request for navigations (#920)

I was thinking on @annevk proposal for `fetchOptions`. You're right on this affects `fetch` standard and it was clear to me when we make it accessible from clients. Perhaps this proposal is more complicated but what about providing a `window.fetchPolicies` namespace (exposed to Service Workers) and keep it separated from Service Workers.

```js
// set or reconfigure
window.fetchPolicies.setNavigationPreload({ headerValue: 'true', scope: '/one-scope' });
window.fetchPolicies.setNavigationPreload({ headerValue: 'true', scope: '/other/scope' });

// clear
window.fetchPolicies.clearNavigationPreload({ scope: '/' });

// access to response.
self.onfetch = evt => {
  evt.respondWith(evt.navigationPreload || fetch(event.request));
};
```

With ergonomics in mind, navigation preload could be set at the same time you register a Service Worker.

```js
navigator.serviceWorker.register('sw.js', { scope: '/one/scope/', navigationPreload: 'true' });
```

What do you think?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/920#issuecomment-248528824

Received on Wednesday, 21 September 2016 07:05:51 UTC