1

I am unable to find details of how Firebase Firestore chooses what to cache locally. The documentation is vague about this. It says that Firestore caches data that the app is actively using.

My requirement is that I need to explicitly set specific collections to be cached locally on the device. Is it possible to do it with Firestore?

pcx
  • 984
  • 11
  • 21

1 Answers1

2

My requirement is that I need to explicitly set specific collections to be cached locally on the device.

There is no way you can specify which collection may exist in cache and which not. By default, Firestore caches all data that your application reads. It's all or nothing.

Is it possible to do it with Firestore?

No, it's not.

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • "By default, Firestore caches all your data." That's a bit oversimplified, and easy to misunderstand. Firestore caches all data **that your application reads**. That is usually significantly less than all data in the database. See my answer here for more on that: https://stackoverflow.com/questions/55590838/how-does-firestore-persistence-really-work/55594373#55594373 – Frank van Puffelen Apr 15 '19 at 14:16
  • @FrankvanPuffelen You're right and thanks again for making it clearer. – Alex Mamo Apr 15 '19 at 14:29
  • Thanks for answering folks. So is it correct to assume that all data that is read/written by my application will continue to be cached by the SDK? – pcx Apr 15 '19 at 14:32
  • @pcx Yes, that's correct. – Alex Mamo Apr 15 '19 at 14:35
  • Awesome, thanks a ton Alex! could you please update your answer for clarity. I have marked it as correct. – pcx Apr 15 '19 at 14:36
  • @pcx Yep, just did. Thanks! – Alex Mamo Apr 15 '19 at 14:41