0

I got the concept of Remote Config in Firebase but while invoking fetch() method on the instance FirebaseRemoteConfig like:

mFirebaseRemoteConfig.fetch(3600)  

one has to pass cache expiration time as here it is 3600. But my question is, why does one have to pass cache expiration in fetch() method?. What is the use of cache expiration in the fetch() method? and What this throttle terminology related to fetch?
I've gone through this documentation https://firebase.google.com/docs/remote-config/android#caching but I didn't get details about the role of cache in fetching data while working with FirerbaseRemoteConfig.

Frank van Puffelen
  • 418,229
  • 62
  • 649
  • 645
Neeraj Sewani
  • 2,662
  • 4
  • 26
  • 41

1 Answers1

3

By calling fetch in your app, you ensure that new configuration values (if any) are retrieved. Retrieving the remote configuration from the server is a relatively expensive operation, so the API is optimize to limit how frequently the values are refreshed. Between these refreshes, the last known values (which may either be the ones you hard-coded, or the ones that were last retrieved from the server) are kept in an on-device cache.

There are two overloads for fetch, one with no parameters, and one with a parameter called cacheExpirationSeconds. The documentation for the latter says:

If the data in the cache was fetched no longer than this many seconds ago, this method will return the cached data. If not, a fetch from the Remote Config Server will be attempted.

So this means that if the remote configuration was retrieved less than cacheExpirationSeconds ago, this call will continue to use the values it already has. If the values were retrieve more than cacheExpirationSeconds ago, this will fetch new values.

The documentation for the parameterless overload of fetch() says:

This method uses the default cache expiration of 12 hours.

So calling this version is equivalent of calling fetch(12*60*60).

Frank van Puffelen
  • 418,229
  • 62
  • 649
  • 645
  • 1
    Did you mean that when some data is passed through Remote Config from the Firebase console is stored in the device cache and then by invoking `fetch()` it is called? – Neeraj Sewani Jun 04 '18 at 08:54