does firebase charge for retrieving docs from firestore js sdk cache?
No it doesn't. If a read is fulfilled from the local cache, it is not charged as a server-side read.
But your code has two get
calls:
// once firebase.firestore().doc('path/to/doc').get() // twice firebase.firestore().doc('path/to/doc').get()
And in this case, the Firestore client has no way to know whether the document was changed between these two calls. So it has to call to the server to determine whether the document was changed, which is (or at least may be) a charged read.
If you need to know the current state of a document in multiple places in your app that execute close to each other (time wise), you should keep an onSnapshot
listener on that document. This ensures that the local cache is always up to date at a minimal cost.