-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support stale-while-revalidate and stale-if-error #27
Comments
It would be great to support these features.
Perhaps there could be a new method like |
I'll work on Maybe the new method could look like this: |
Yeah, that looks good. |
I started implementing this and realized that my proposal for So I think this has to be done with a new method |
Ah, right. So together with |
I think
What do you think? I am happy to help with the implementation |
If you're implementing it in parallel with an actual HTTP client I'm confident it'll make sense. |
The implementation is ready here: #30 |
Hi @kornelski, thanks for your work on this library, it looks fantastic.
For my use case, I would need the library to support these two
Cache-Control
directives. From MDN:stale-while-revalidate=<seconds>
: Indicates that the client is willing to accept a stale response while asynchronously checking in the background for a fresh one. The seconds value indicates for how long the client is willing to accept a stale response.stale-if-error=<seconds>
: Indicates that the client is willing to accept a stale response if the check for a fresh one fails.I think it could be implemented in the following way:
satisfiesWithoutRevalidation()
would check thestale-if-error
directive and returntrue
if the response is a 5XX and the stale response can be used.satisfiesWithRevalidation()
would check thestale-while-revalidate
directive and returntrue
if the stale response can be used while revalidating in the background. The caller would be expected to make the request while also using the cached response.If you're open to these enhancements, I'd be happy to work on them.
The text was updated successfully, but these errors were encountered: