Native Storage & Ionic storage : persist data OR just Cache data

I am reading about Local Storage and I am quite confused.
Native Storage & Ionic storage : which one persist data and still saved after stoping application or turn off and on application , and which one is just cache data and it will be removed automatically.
i’m using ionic3 :wink:
thnks in advance

Neither. Both will persist data between app restarts.

Local Storage is the one you’re thinking of that may or may not persist between app restarts.


Okey, what about if i want implement local Storage which plugin or ionic module use ?

Err, I’m not sure why you’d want to, but you’d just use localStorage just like in browsers.

in my ionic 3 application i must get a lot of data from a backend using REST.
i want to save data in json on mobile devise cache for first time.
and then just read data from cache and if it(data on backend) change i read new data from backend and update my json data.
i want to be my application more faster.

1 Like

This is discouraged, because different platforms handle local storage differently. So your app’s behavior miught be inconsistent. Use Ionic Storage with the sqLite plugin, and put the storing and processing inside a web worker if you’re concerned about lag.

1 Like

my goal is to be my application more faster, actually i get data json from a backend each time when page loaded but that’s not good for me, for that reason i want to get data just for first time in save it somewhere on device and in next time when page loaded i need something like if data changed on server i will get new data else just read from local.
i think it’s clair my requirement

And you can’t keep it in a variable in a provider because why?

beacause if i stop application and run it again it will request backend again but i don’t want that i mean request back just if there is change

Then you need longer term storage than local storage. Either build a simple cache yourself with eg SQLite, or use a backend as a service that provides caching, like Firestore.

ok i think that the right way is to build cache with SQLite or ionic storage