-
-
Notifications
You must be signed in to change notification settings - Fork 935
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
Caching: stale-if-error rfc5861 #1059
Comments
I think this change would be probably enough to have the feature here |
Hey @szmarczak @sithmel has this been implemented? In the docs I see that stale entries are revalidated, but I don't see anything about stale-if-error / stale-while-revalidate. |
Hi, The change to http-cache-semantic has been released. I was about to follow with a change to cacheable-request. But I never finished the work. @marcoreni @szmarczak let me know if you are interested in picking this up. I can give some direction on how I was planning to do it |
So this is finished, no?
Hmm... What is left to do here?
Sure, that would be great. |
The code works but I think it should be possible to log or "do something" when the server return 500 or times out, and we are using the stale content. Here's my commit to http-cache-semantics kornelski/http-cache-semantics@1b35980 In case of errors, if the use-stale-if-error header is used, the if(this._useStaleIfError() && isErrorResponse(response)) { // I consider the revalidation request unsuccessful
return {
modified: false,
matches: false,
policy: this,
};
The code in cacheable-request uses the The missing part in cacheable-request is that it should also fire an error event, so that you should be able to detect when the server is throwing an error. In I hope this helps |
Well. If it gives us 500 and it is valid to reuse the cached response then no error should be emitted. |
I don't think it does @szmarczak https://github.com/lukechilds/cacheable-request/blob/master/src/index.js#L89 |
What problem are you trying to solve?
Fallback on stale cached content when the server is down or returns an error (500)
Describe the feature
https://tools.ietf.org/html/rfc5861
https://docs.fastly.com/en/guides/serving-stale-content
Checklist
The text was updated successfully, but these errors were encountered: