1

Assuming my rules are setup to user read/write on owned object only, I want to know what data does firebase client (IOS/Android) store in devices? In this example, does it download the data that doesn't belongs to the user as well on the device but just blocked it? or only object owned by user will be downloaded on device.

Is there a way to just have some of the child object saved in the cloud only but not locally? I am worried about the db size getting too large in the devices.

Thanks!

KENdi
  • 7,576
  • 2
  • 16
  • 31
bruce
  • 31
  • 1
  • 5

1 Answers1

0

Your Firebase app will only have access to data in the database that the rules permit. Security is handled by the Firebase Realtime Database (not the app) so only data that the user is allowed to access will be downloaded.

In order for your app to work with data stored in the database, it needs to be downloaded to the device. By default, data is cached so that your app still works even if your device temporarily loses its network connection. The app only stores this locally if you enable offline capabilities to allow the app to continue working when no network is available.

Firebase apps automatically handle temporary network interruptions. Cached data is available while offline and Firebase resends any writes when network connectivity is restored.

When you enable disk persistence, your app writes the data locally to the device so your app can maintain state while offline, even if the user or operating system restarts the app.

The Firebase app will automatically handle all of this functionality for you.

The size of the local cache will rarely be large enough to worry about, unless you are storing or downloading huge amounts of data, which is not recommended. If your database is large, you should implement strategies to restrict queries to only retrieve relevant data by filtering or paginating your queries.

Community
  • 1
  • 1
Grimthorr
  • 6,856
  • 5
  • 41
  • 53
  • What I am more interested to know is if all objects within the database are downloaded into local device? or just the objects which the owner has read/write rights are downloaded to device? – bruce Oct 13 '17 at 20:32
  • Only the objects that the user has read/write access to are downloaded to the device. – Grimthorr Oct 13 '17 at 20:33
  • Great.. Thanks for the clarification. What is the best design pattern if I want to for instance save some logging messages to my realtime db but doesn't want it to live in local devices because no reading will be needed in client? – bruce Oct 13 '17 at 20:41
  • If you write to the database with offline capabilities disabled, I don't think the app will keep this data cached once it's sent. If this answers your question, please don't forget to accept it by clicking the tick under the vote buttons, thanks! – Grimthorr Oct 13 '17 at 20:50