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
{{ message }}
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
I'm in a situation where I'm not sure if I have to write my own handler, or if there is a combination of settings that allow me to accomplish the following use case:
I have requests that cannot be cached on cdn (because of user tokens), but for a single user I would like to cache that response for say an hour. In that time I would like to serve from the cache, but also hit the network to update in the background when new data came in.
After an hour since the last request (let's say the next day), I always want to hit the network, because at that time the chance is higher that the response will be changed.
I think this can be accomplished by using fastest combined with maxAgeSeconds.
I would like to have cached requests available for offline use later on.
Using maxAgeSeconds makes this impossible, since the cache entires will be removed.
When removing the maxAge, and still using 'fastest' for scenario 1, you end up being served an older entry and need a 'reload' before getting the new one.
custom handler
Thinking about this, when writing my own handler, I would probably want to introduce a new option (e.g. maxAgeSecondsFresh) and use that value as a condition for which strategy to use (and not delete the cache). When in that timeframe, use 'fastest', when outside that timeframe, use 'networkFirst'.
(And when no connectivity at all, cacheOnly should probably be chosen there).
This seems like a pretty common scenario. Maybe something that can be included in (a future version) of sw-toolbox? Any pointers are welcome as well!
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm in a situation where I'm not sure if I have to write my own handler, or if there is a combination of settings that allow me to accomplish the following use case:
After an hour since the last request (let's say the next day), I always want to hit the network, because at that time the chance is higher that the response will be changed.
I think this can be accomplished by using
fastest
combined withmaxAgeSeconds
.Using
maxAgeSeconds
makes this impossible, since the cache entires will be removed.When removing the maxAge, and still using 'fastest' for scenario 1, you end up being served an older entry and need a 'reload' before getting the new one.
custom handler
Thinking about this, when writing my own handler, I would probably want to introduce a new option (e.g.
maxAgeSecondsFresh
) and use that value as a condition for which strategy to use (and not delete the cache). When in that timeframe, use 'fastest', when outside that timeframe, use 'networkFirst'.(And when no connectivity at all, cacheOnly should probably be chosen there).
This seems like a pretty common scenario. Maybe something that can be included in (a future version) of sw-toolbox? Any pointers are welcome as well!
The text was updated successfully, but these errors were encountered: