To reduce network traffic, we only want to fetch the data if necessary.
This can be achieved by caching the data with some defined (flexible) timeout parameter, such that when the data is requested:
if cached data does not exist or is older than timeout - fetch and return new data and update the cache
if cached data exists and is more recent than timeout - return cached data without calling api
To reduce network traffic, we only want to fetch the data if necessary. This can be achieved by caching the data with some defined (flexible) timeout parameter, such that when the data is requested: