- From: Ben Kelly <notifications@github.com>
- Date: Thu, 11 Dec 2014 11:20:15 -0800
- To: slightlyoff/ServiceWorker <ServiceWorker@noreply.github.com>
- Message-ID: <slightlyoff/ServiceWorker/issues/573/66672253@github.com>
@jakearchibald, I was thinking more about this:
> do you think this is a sensible thing to live in Fetch? An option to only get the response if it's
currently in-flight.
```
fetch('/').then(function(response) {
// ...
});
fetch('/', {
onlyInFlightStuffPlease: true
}).then(function(response) {
// ...
});
```
It seems the browser would have to cache the in-flight responses somewhere. With multi-process architectures, this may not be super straightforward.
I still think this would be better to add to Cache. Instead of implicitly creating a cache we would explicitly expose the capability on the API available to content. Then libraries could implement a "in-flight only fetch" feature using this primitive.
For example, lets say we added `{ fetchIfMissing: true }` and `{ bodyComplete: true }` to QueryParams, then a library could do something like this:
```
function fetchInFlightOnly(request) {
var cache;
return caches.open('FetchInFlightOnly').then(function(c) {
cache = c;
return cache.match(request, { fetchIfMissing: true });
}).then(function(response) {
cache.delete(request, { bodyComplete: true });
return response;
});
}
```
---
Reply to this email directly or view it on GitHub:
https://github.com/slightlyoff/ServiceWorker/issues/573#issuecomment-66672253
Received on Thursday, 11 December 2014 19:20:46 UTC