简体   繁体   中英

Does Firestore not charge for documents that are cached and unchanged in a Read query with persistence enabled?

My assumption was that Firestore would not consider the client cache when evaluating Read usage. However, when I have persistence enabled in my application, it seems I can run the same queries endlessly and not see any change in my usage metrics. I've tested this over and over - when persistence is disabled, I see the usage metrics go up.

Given the amount of testing I've done, I feel that I should be able to safely declare that Firestore must be recognizing my local cache and only charging me for Reads on updated documents. However, I cannot find documentation around this anywhere, and I have combed through the docs. I'd certainly think if Google wasn't charging me for these cached Reads that they would want to highlight that benefit, whereas they really only highlight enablePersistence as an offline benefit - so I am perplexed.

Does someone have some insight into what is going on here?

  • Example enable persistence: firebase.firestore().enablePersistence()
  • Example query: myCollection.where(condition).get()

According to this documentation

Offline data persistence feature caches a copy of the Cloud Firestore data that your app is actively using, so your app can access the data when the device is offline

So, it is clear that you will only be charged when calling get() on the server to-read documents, mentioned in this answer

Also, be aware that

  1. Offline Persistance is enabled by default for Android and iOS .
  2. The pricing model for Cloud Firestore

This is a really great question. To clarify what the question is asking: "If my app is online and makes a query, but the query is fully returned by the offline cache, will I still be charged?"

I suspect yes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM