You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While exploring a possible solution to #1857 I discovered that our caching strategies do not provide a mechanism for observing when the cache write finishes. Similarly, the StaleWhileRevalidate strategy (which makes both a cache read and a network request) does not provide a way to know when the network request has finished.
In all of these strategies we're using event.waitUntil() to keep the service worker alive until all work is done, but that information isn't exposed to users of the strategies, so there's no way to observe when a strategy is actually "done".
In the case of precaching, this is fairly important, so any solution to #1857 is probably dependent on solving this issue first.
A straight-forward solution (but also a breaking change) would be to return an object in the form of {response, done} rather than just returning a Response. Alternatively, to avoid a breaking change we could add a new property to the object passed to makeRequest() that gets resolved once all waiting is done.
(The first option seem cleaner, so my preference would be to time this with the next major release, since I don't think many people are manually using makeRequest() at the moment)
The text was updated successfully, but these errors were encountered:
If this is something that was just done internally and affected the makeRequest() return value, and didn't affect the public handlerCallback interface, the first option sounds fine to me.
@philipwalton would you also consider adding a way of knowing the outcome of the initial cache read when using StaleWhileRevalidate as explained in #2010 ?
Library Affected:
workbox-strategies
While exploring a possible solution to #1857 I discovered that our caching strategies do not provide a mechanism for observing when the cache write finishes. Similarly, the
StaleWhileRevalidate
strategy (which makes both a cache read and a network request) does not provide a way to know when the network request has finished.In all of these strategies we're using
event.waitUntil()
to keep the service worker alive until all work is done, but that information isn't exposed to users of the strategies, so there's no way to observe when a strategy is actually "done".In the case of precaching, this is fairly important, so any solution to #1857 is probably dependent on solving this issue first.
A straight-forward solution (but also a breaking change) would be to return an object in the form of
{response, done}
rather than just returning aResponse
. Alternatively, to avoid a breaking change we could add a new property to the object passed tomakeRequest()
that gets resolved once all waiting is done.(The first option seem cleaner, so my preference would be to time this with the next major release, since I don't think many people are manually using
makeRequest()
at the moment)The text was updated successfully, but these errors were encountered: