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

* We need to make sure this header doesn't get copied over on redirect
* Some users are detecting the `Service-Worker` header and thinking it's a SW script request, so we should use a different header: `Navigation-Preload: true` by default, but can be set to any value
* It'd be nice to have self.<something> that refers to *this* service worker instance in a service worker global (`self.own`)
* The header needs to be settable at any point
* The setting should live with the lifecycle of the service worker
* Need a way to clear it

```js
// this can be called at any point
registration.active.setNavigationPreload({
  value: 'true' // header value
}).then(() => console.log(`It's set!`));

registration.active.getNavigationPreload()
  .then(settings => console.log(settings.value));

self.addEventListener('fetch', event => {
  event.respondWith(event.navigationPreload || fetch(event.request));
});
```

@jakearchibald to propose API

-- 
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-248305875

Received on Tuesday, 20 September 2016 13:57:33 UTC