This topic explains how context caching to local storage works for SDKs that support the feature.
About context caching
Most newer client SDKs use local storage to cache flag values for unique contexts by default. On subsequent launches, the SDK reads the cached values before any network connection is established. The client still initializes and connects to LaunchDarkly’s service to fetch the most recent flag values, but it is not dependent on those values to reach its ready state. The SDK updates values in the background after connecting to LaunchDarkly.
Some SDKs let you configure the maximum number of unique contexts that can be cached locally by setting maxCachedContexts at startup. This allows you to control the amount of local storage used for storing contexts.
When you call identify, the number of cached contexts increments. If the number of cached contexts exceeds maxCachedContexts (5 contexts by default), the SDK deletes context data in excess of maxCachedContexts, starting with the oldest context first.
For SDKs that support configuration, set maxCachedContexts to 0 to disable caching flag values for contexts in local storage and clear any stored data. Setting disableCache to true disables caching context data to local storage but leaves any existing local storage in place.
Client-side SDKs
These SDKs enable local storage caching by default, and you can optionally configure the size of the cache as necessary:
Some SDKs use the same implementation for both bootstrapping and local storage caching. For these SDKs you cannot configure both bootstrapped flag values and local storage caching. The following SDKs provide the option to use either bootstrap flag values or enable local storage caching, but not both:
For the above SDKs, local storage is not enabled by default. You can optionally enable local storage caching, but you cannot configure the cache size.
