explorer
explorer copied to clipboard
Cache responses from the API to improve availability
Is your feature request related to a problem? Please describe. When the API is bogged down by heavy traffic, or unavailable, the Explorer fails to render any pages and becomes unavailable. The Explorer also adds a significant amount of traffic to the API and its proxied stacks-nodes.
Describe the solution you'd like
The Explorer should cache GET
request responses from the API for a limited time, and prefer returning the cached responses instead of reaching out to the API until the cache expires. At which point the cached responses would be re-fetched from the API as live requests come in, updating the cache as a result.
If the API is unavailable when attempting to update a cached response, the Explorer should return the stale cached response with a banner at the top of the page which states the returned data may be outdated, and to try checking back later.
I would suggest adding support for a third-party in-memory caching service, like Redis, for this feature request rather than implementing something custom internally. Ideally, this feature would be optional and would be disabled by default, allowing users to still easily spin up their own Explorer.
@beguene Is this still relevant after the move to CSR? if it isn't lets close it
Yes with the CSR everything will be cached by default. It's already the case for many calls now, we just have a few more to tackle (what I am working on https://github.com/hirosystems/explorer/issues/809)
this should be done