Jeff Becker
Jeff Becker

Reputation: 125

Firebase cache when still online, iOS

In the iOS Firebase SDK, if I perform a .ChildAdded query, for example, and then later perform the same query again, will the query perform on the local cache or will it hit the Firebase servers again?

Upvotes: 1

Views: 637

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599571

In general: the Firebase client tries to minimize the number of times it downloads data. But it also tries to minimize the amount of memory/disk space it uses.

The exact behavior depends on many things, such as whether the another listener has remained active on that location and whether you're using disk persistence. If you have two listeners for the same (or overlapping) data, updates will only be downloaded once. But if you remove the last listener for a location, the data for that location is removed from the (memory and/or disk) cache.

Without seeing a complete piece of code, it's hard to tell what will happen in your case.

Alternatively: you can check for yourself by enabling Firebase's logging [Firebase setLoggingEnabled:YES];

Upvotes: 1

Related Questions