#caching and updating API data for faster response times.

5 messages · Page 1 of 1 (latest)

abstract root
#

I want a way when a user requests a payload collection, a hook will fetch the API and retrieve the JSON data. This data will be stored in collection in JSON format. The next time user requests the same payload collection, our collection will return the cached data instead of fetching the API again, providing faster response times.

However, we also want that the data is up-to-date, so in the background, it will still fetch the API to get the latest data, even though the cached data is being returned to the user. How can I do that???

ancient kestrel
abstract root
#

It is caching the collection data but not updating when a use a fetch the data. afterRead hook is not executing when user sending request to that end point . I am using field level hook . But previously it was executing for every red of that collecting now it it only executing only for the first fetch and update not for read time

#

In this photo that Json field a generating it is fetching and external API

#

@ancient kestrel sir previously it was fetching the API every request and user was getting response after 1-2 second because of background fetching . Now I also want that it will fetch the api in background but it will provide previous response as cache. But it stop sending request to the external end point . I am using this "Redis-cache Plugin"