4

I am using angularfire's sync arrays and the javascript SDK of firebase.I need to download about 5MB of data to fill my array so the app could work offline for a short time if it loses connection. I am afraid that the way I do things, the size of this array can easily bring me a high bill at the end of the month.

What if the user refresh's or starts and stops his/her app 100 times a month? What if 100 users do it? Is there some way to cache the array offline and only apply changes to it after I refresh the app?

Peter Zlatev
  • 67
  • 1
  • 5
  • The JavaScript SDK for the Firebase Realtime Database can handle short-term connectivity loss: it keeps the listened-to data in memory and will keep a queue of writes. It can however not survive a page reload. Since this has been asked a few times before, I'll provide some links: [1](http://stackoverflow.com/q/40954993), [2](http://stackoverflow.com/q/38423277), [3](http://stackoverflow.com/q/32530190) – Frank van Puffelen Jan 19 '17 at 14:23
  • If you need to download and maintain 5MB of data that changes frequently and should be updated in real-time, then it's going to be expensive. That's a LOT of JSON data. What is the end goal? Are you trying to cache images locally? There's no way a client needs 5MB of chat messages, for example, locally cached. Also, have you tried storing it in localStorage? There's just not enough here to help you. See [how to ask](http://stackoverflow.com/help/how-to-ask) and [creating an mcve](http://stackoverflow.com/help/mcve). – Kato Jan 19 '17 at 17:05
  • I want to download a list of products.Name, price, and several other specification so the user can make sales even if there is no internet for a long time.Products can be 20000 as an example.And i will need the second array with products barcodes which also could be 20000-30000 records with simple 10 character strings.The data wont update frequently.Only the user can make changes to products. – Peter Zlatev Jan 20 '17 at 12:56
  • Hi @PeterZlatev, I would recommend you to look at cloud function to expose product data (assuming it does not change very frequently) and use cache from your cloud function. – Sanchit Nov 04 '17 at 06:48

1 Answers1

1

I suggest that you take a look at AngularFire Offline which I am using for a similar use case within an Ionic hybrid mobile app and so far it looks to handle things well.

Peter Scott
  • 1,318
  • 12
  • 19