Request for advice / best practices for offline sync

Hey all,

I’m creating v2 of our app in Ionic. We already have an open API which we will be using to get the data used in the app, which we are forced to use due to our tech stack.

I want the app to be make requests for the data when offline, and when offline sync data.

I’ve found a number of good posts on the area, such as
https://blog.ionicframework.com/building-an-ionic-app-with-offline-support-part-1/

however nothing that specifically talks about doing this generically for all REST calls.

I was wanting to know if something like this is best practice for ionic development, or if I’m missing a far better way to do this.

Firestore offers this “for free” as part of their service. Which makes them very attractive to me. I had actually built my own cache manager, and it had passed some tests, but handing off that potential source of weird runtime issues sounds great.

It’s a nontrivial problem, and the few blog posts I’ve seen about it solve simpler problems than the real thing (even if they claim to solve the real thing). If you’ve set aside the time, and are ready for a learning experience, then go ahead and roll your own!

Isn’t that sort of situation what service-workers are meant to handle? (Not a rhetorical question)

Hey Aaron,

I couldn’t find a good tutorial todo that through Firestore & it looked like you have to pay extra todo that functionality. Did you spot a good example of this, am I being blind!

Hey Jaydz,

Thanks for the response…
That sounds like the correct sort of thing, but I kinda see that as a potential underlying technology to a solution. I’m surprised if the correct recommendation is to write it from scratch, as seems like it’s something that most people writing an app using ionic would have to do.

https://firebase.google.com/docs/firestore/manage-data/enable-offline