Re: [slightlyoff/ServiceWorker] Eliminating SW startup latency for common case (#920)

@ykahlon 

> We actually need a simpler solution

But just to clarify, the idea above works for you too?

> we would like the SW to make the preflight request and only if the SW decides to make the exact same request, it will be handed to the SW (the SW doesn't need to know whether it was a preflight request).

So does that mean your implementation would look something like:

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

…where `preloadResponse` is a promise for a response fetched using `event.request` plus optional headers.

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

Received on Monday, 22 August 2016 09:54:42 UTC