Re: [w3c/ServiceWorker] Tee-ing Cache.put()? (#1367)

Given the current API, I believe you're supposed to schedule the `cache.put` using `waitUntil`. Not sure if this is actually necessary given the browser implementations, but probably best practice:

```JavaScript
const fromNetwork = fetch(url);
event.waitUntil(fromNetwork.then((response) => {
  return cache.put(url, response);
}));
event.respondWith(fromNetwork.then(response => {
  return response.clone();
}));
```

Either way, seems like a common enough pattern to warrant some syntactic sugar.

-- 
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/1367#issuecomment-434499403

Received on Tuesday, 30 October 2018 22:55:04 UTC