Using Cache

Hi All,

My app requires some user information from APP DATA to be loaded at the start of each page in order to power other logic. I’ve noticed that when the page is refreshed that the screen goes blank and I end up needing to re-login into the app and navigate to my page. I can’t find anything in the videos or documentation, but I’m wondering if there is an opportunity to use the cache or local storage to avoid this issue. Does anyone have any suggestions?

Here’s the error if helpful

Thanks

Hi.
I see two problems here.

(1)

I’ve noticed that when the page is refreshed that the screen goes blank and I end up needing to re-login into the app

If the user is logged in, the refreshing of the page shouldn’t force him logout. Maybe you have some business logic which is performed on page reload?

(2)
You may use a block “App Data” in order to put some data into the app cache. (look at the top of Frontend → UI-Builder → Logic)
Or if you want more flexibility consider to use Hive API.

Hi Oleg,

Thanks for the quick response. I’m actually already leveraging App Data, but am getting the error shown above. Is there another way to use it that you were thinking of?

This is true only if you use the “stay logged in” option in the login API.

I’ll expand on the answer a bit.
In case when cookies are enabled a user-id token is sent during a page refresh. It makes a user stay logged in too.