Re: [ServiceWorker] Can caches store and retrieve results that are still being written to the cache? (#573)

…yeah, and if we ever need to speed up ServiceWorkers by running multiple instances at once, we break this.

The low level pattern here is:

1. Is it in the cache? If so, serve it & abort
1. Is it currently being requested? If so:
  1. Wait for response (headers only)
  1. If response it's not a network failure, serve it & abort
1. Fetch it via the network
1. Wait for response (headers only)
1. Put response clone in the cache
1. Serve response

The bit we're missing is 2. It's not totally simple, as we don't know if the in-flight request is really a match for our request until we have headers, as matching can be affected by vary headers on the response.

@slightlyoff suggested that the networking layer of the browser should just take care of 2. I'm not so sure it's safe or desirable to do that. Any idea what Gecko does here?

---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/573#issuecomment-66496337

Received on Wednesday, 10 December 2014 18:14:04 UTC