I wondering if enabling offline support in the clients for the Firebase Realtime Database saves you any bandwidth? I wonder if the Firebase client when starting loads the database from storage and then continue on and only syncs the stuff that has been added later? Or does it sync everything and if that doesn't work fallbacks to the offline data that he has stored before.
If you are using FirebaseDatabase.getInstance().setPersistenceEnabled(true); means that you'll be able to query your the database even if you are offline. This is happening because Firebase creates a local copy of your database. Every change that is made while you are offline, will be updated on Firebase servers once you are back online. So this option is not used to save bandwidth, is to enable offline capabilities.
To be more clear, every client that is using a Firebase database and uses setPersistenceEnabled(true) maintains it's own internal (local) version of the database. When data is updated, it is first written to this local version of the database.
As a result, all writes to Firebase will trigger local events immediately, before any data has even been written to the server. This means that the app will remain responsive regardless of Internet connectivity.
Once the Internet connectivity is reestablished, you'll receive the appropriate current server state. The Firebase client synchronizes that data with the Firebase servers and with other clients that are using the same database.
Another thing to remember is that Firebase automatically manages connection state to reduce bandwidth and battery usage. When a client has no active listeners, no pending write or onDisconnect operations, and is not explicitly disconnected by the goOffline method, Firebase closes the connection after 60 seconds of inactivity.
As a conclusion, there is no difference regarding bandwidth when we are enabling offline support. The benefit is that we can query and change the database even if we are not connected to the internet.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With