Idan Aviv
Idan Aviv

Reputation: 1293

Will retrieving a document that is already cached offline will count as read?

In my app that everytime the user opens its profile page, the app will get a single document containing it profile information for Firestore. So the first time the user will open the app it will download the document from Firestore server and then it cached offline on the device (offline persistence turn on). Now let say that user closes the app and open it again, still online, open its profile page, and user document didn't change. Will Firestore retrieve the document from the cached? Or will it download it again from Firestore (and count as another read)?

Upvotes: 2

Views: 217

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317477

The whole point of local persistence is to cache documents previously read, so that they don't require another read from the server in the future. So, no, the SDK should not read the document from the server the second time.

You can verify this for yourself by checking the metadata associated with the document to find if it was obtained fromCache.

Upvotes: 3

Related Questions