Add ETags for optimized caching #3560
Unanswered
NurMarvin
asked this question in
API Feature Requests & Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently caching data received from the API is pretty hard to cache effectively. Of course there is gateway events that update the client about certain changes, but not only do some bots not even connect to the gateway, but there's also certain things that don't have gateway events that would inform the client about changes. Therefore there is no way to check if the cached data for those things is still up to date, or if it has changed already, without making a new request and checking the content of the response from the API against the cached version.
This is where
ETag
s could come to the rescue: The API sends aETag
header with the uncached response, which is a uniquely generated ID for the current state of the content, so that the client can save it and send it with any future requests in aIf-None-Match
header which indicates to the API, it should only return data if the ETag for the content does not match up with the one in said header, otherwise it should send a304 Not Modified
.For bots, this would have to be implemented in bot libraries (or maybe some HTTP client libraries might already support it out of the box) to be effective, but since the official client is just a glorified browser, it would automatically benefit from the changes as well, since ETags were created for browsers and are already implemented there.
For more information about ETags, refer to the MDN Web Docs entry: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
Beta Was this translation helpful? Give feedback.
All reactions