For a new project we want to experiment with Firebase Database, the idea is to store SEO, Product, User Preferences and so on.
We are expecting that the SEO data will be the bigger space consumer and the client doesn’t need to save this information locally as will be only used for statistical purposes
Is it possible to enable Firebase Database Persistence only on certain nodes and exclude others?
Thanks for your help
2
Answers
Persistence can only be configured all or nothing. This is true for both Realtime Database and Cloud Firestore. There is no granular persistence setting. Please feel free to file a feature request.
To do this you can configure two separate firebase instances – one with persistence turned ON and another one with persistence turned OFF, even if they both point to the same database (or you can configure for several different databases – that exactly what it was created for).
The example below is in Swift, but I suppose there should be equivalents on other platforms:
When I want to access a database with persistence I address a shared database via
Database.database().reference()
and in case I need fresh data I refer to the non-persistent one viaDatabase.database(app: FirebaseApp.app(name: "DatabaseWithoutPersitence")!).reference()