Does User.getIdToken() (with parameter forceRefresh = false) retrieve the ID token from the server every time it's called? Or does it cache it, and only contact the server when it detects that a refresh is due (or do something else entirely)?
And a follow-up question - if it indeed does retrieve the ID token from the server every time, doesn't that mean that every time an app wants to send a request to its backend server (which has to include the ID token, so that the backend can verify the authenticity of the request), it effectively has to first contact the Firebase server to get the ID token? Because that's going to get expensive, right?
I know I can listen to the idTokenChanges stream and cache the ID token whenever I get a new User instance, but I'd prefer to not have to do that, because I don't want a StreamBuilder/StreamProvider to rebuild UI whenever the ID token changes. Listening to authStateChanges instead means the UI can rebuild only on sign-in and sign-out events, which is what I want. But then I run into the potential problem described above (if indeed the server is queried every time), i.e. I have to call getIdToken() every time I want to send a request to the app's backend.