Ionic 5 capacitor : Load the data of a page only once even if the page is loaded 1000 times

Good evening, please help me.

I am developing a mobile application and I would like to be able to retrieve data from the page only once: Load data the first time when the page is loaded by the client.

The problem is that when I put my function in the constructor or in ngOnInit, this function is called each time the user loads the page (which I don’t want: I want the data to load only the first time and that’s it). If the user wants new information about the page, he has to refresh the page manually .

Is this possible? Thank you for your help.

This is a cousin of a very typical question here, which is addressed here, and my fundamental suggestion is the same: don’t use lifecycle events to manage data freshness. In your case, once you get all the data wrangling out of the page and into a service where it belongs, the service can simply fetch data only on request, and it won’t matter how many times the page asks the service: the answer will be unchanged until somebody asks the service to update it.