Is it ever necessary to use a waitUntil inside a respondWith (itself within a fetch event)? Doesn't respondWith already waitUntil it receives a resolved promise?
Some discussion of this is here, in which the following simple example is given in which both are used:
addEventListener('fetch', event => {
event.respondWith(
fetch(whatever).then(response => {
event.waitUntil(addThisToTheCache(response));
return response;
})
);
});
But couldn't this be written without a waitUntil? As follows:
addEventListener('fetch', event => {
event.respondWith(
fetch(whatever).then(response => {
return addThisToTheCache(response).then(() => {
return response;
});
})
);
});