- From: Luke Wagner <notifications@github.com>
- Date: Tue, 30 Oct 2018 19:18:51 +0000 (UTC)
- To: w3c/ServiceWorker <ServiceWorker@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Tuesday, 30 October 2018 19:19:13 UTC
IIUC, a common pattern developers would write when lazily populating a `Cache` would be something like: ```js event.respondWith(fetch(url).then(response => { var responseClone = response.clone(); cache.put(url, response); return responseClone; })); ``` With a new method `teePut` (placeholder name, better names welcome!) a developer could write: ```js event.respondWith(fetch(url).then(response => cache.teePut(url, response))); ``` where `teePut` returns a `Response` (or maybe `Promise<Response>`) that is semantically a clone of the `Response` given as argument. In addition to being simpler to write, this might be more optimizable by the browser for two reasons: * the constrained form of the tee, compared to a general `clone()`, may allow less internal copying between source and sink streams * if the response clone flows into one of [several](https://v8.dev/blog/improved-code-caching) [content](https://blog.mozilla.org/javascript/2017/12/12/javascript-startup-bytecode-cache/) [sinks](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/compileStreaming) that want to cache a processed form of the resource, the explicit tee operation provides a more-direct route from the content sink back to the Cache entry. -- 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
Received on Tuesday, 30 October 2018 19:19:13 UTC