explorer icon indicating copy to clipboard operation
explorer copied to clipboard

Cache responses from the API to improve availability

Open CharlieC3 opened this issue 3 years ago • 2 comments

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.

CharlieC3 avatar Dec 23 '21 15:12 CharlieC3

@beguene Is this still relevant after the move to CSR? if it isn't lets close it

andresgalante avatar Aug 09 '22 16:08 andresgalante

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)

beguene avatar Aug 10 '22 05:08 beguene

this should be done

andresgalante avatar Jun 19 '23 22:06 andresgalante