Caching API Data

Sometimes data APIs have restrictions like limits for requests per IP or hourly request limits. In cases like these, it’s useful to have data cached for your user. You can do this by using the state management component in Wappler.

In App Structure add new component:

Then open the State Management category. In this tutorial we will show you how to cache the data in the local storage, but you can also store it in a session if you like. So - we select local storage manager:

Then, select your API Data Source and in the properties select the local storage manager we just created:

Add the time to cache your data for (in seconds) and you are done:

Now, when our users reload the page in the next 3600 seconds, the API won’t be called and the data will be loaded from the local storage.