Caching API Calls & Reuse on multiple pages

I am building a site that connects to various API’s. The main page is a centralized dashboard which makes a number of API calls. This page will have a lot of views & the content area of it will be the same for all users on the site. I have seen custom states used inside of a page to reuse the API call, but I have not yet seen how to take one API call and use it on multiple pages.

Can API calls be cached & used on multiple pages?

You can save api data to your database. If the calls are the same for all users you can then make it so the pages that require this data look to your database. If the calls are different for each user, you may want to use the created by field as a constraint to show only the correct call data for that user.

2 Likes

I have been considering it. Still looking for options.

Look into how to pass data between pages. Knowing the ways you can do that, will help you to understand the way to accomplish your desired ‘cache’ of API call is most likely going to require you to save it to the database, unless there is some way of referencing the result of the call to pass to another page, which from my experience, I do not think is possible.

1 Like