Offline Support
Koolbase caches your feature flags, remote config, and version policy locally so your app works even when there is no network connection.
In the browser
What gets cached
On the first successful SDK init, the bootstrap snapshot is persisted to local storage using shared_preferences. This snapshot includes:
What is not cached
First launch with no network
On the very first launch, if there is no network connection and no cached snapshot exists, the SDK initialises with empty state. Every flag check returns false and every config read returns its fallback.
This means your app will work on the very first launch offline — as long as you have defined sensible fallbacks for every flag and config key.
// Initializing is safe with no network
await Koolbase.initialize(const KoolbaseConfig(
publicKey: 'pk_live_...',
baseUrl: 'https://api.koolbase.com',
));
// No network and no cache: no flags, no config, no version policy
// These all return their fallbacks safely
final show = Koolbase.isEnabled('new_ui'); // false
final url = Koolbase.configString('api_url',
fallback: 'https://api.myapp.com'); // the fallback
final ver = Koolbase.checkVersion(); // upToDateCache refresh
The SDK refreshes the cache in the background on a polling interval (default: 60 seconds). When a fresh snapshot is fetched, the in-memory state and the local cache are both updated atomically. Flag and config reads after the refresh return the latest values.
// Flutter: change how often it refreshes (optional)
await Koolbase.initialize(const KoolbaseConfig(
publicKey: 'pk_live_...',
baseUrl: 'https://api.koolbase.com',
refreshInterval: Duration(seconds: 30),
));Cache TTL
The cached snapshot does not expire automatically. If the app is launched offline, the last known snapshot is used regardless of how old it is. This ensures consistent behaviour in poor network conditions — your users always see something rather than a broken state.
Stale cache is better than no cache
Listen for cache updates
If you want to react when new flag or config values arrive from the server, listen to the update stream:
// Listen for snapshot updates
Koolbase.onUpdate.listen((_) {
// New flags/config loaded — refresh your UI if needed
setState(() {});
print('Koolbase snapshot refreshed');
});