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
Make HTTP errors cacheable #4
Conversation
* Changes the underlying cached format * Now caches an object, not just the response body * This is to make way for caching the error object
* Stores all of the properties of HTTP errors in the cache * Message, statusCode, body * Recreates error objects when pulling them out of the cache * We can't store Error objects in JSON so we need to recreate them
statusCode: err.statusCode, | ||
body: err.body | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're storing everything we need to recreate a proper Error
object.
Note that we're free to change the cached object structure in any release because the cache key includes the version number of the library. |
👍 |
Looks like a good idea! 👍 |
👍 |
Make HTTP errors cacheable
cache-control
headerbody
property or anerror
propertyerror
property contains everything we need to recreate anError
object when we pull it out of the cacheerr.message
,err.statusCode
,err.body
Error
objectsA valid response is cached as:
A HTTP error is cached as: