The Offline-First SDK lets applications use feature flags without an internet connection. Flags are cached locally and synced automatically when the connection is restored.
Flags are cached on the device for offline access.
Features: Persistent storage (SQLite, SharedPreferences, UserDefaults), automatic caching on load, cache size limits, TTL-based invalidation.
Example:
val manager = FlagentManager(
baseUrl = "https://flags.example.com/api/v1",
offlineStorage = SQLiteOfflineStorage(context),
cachePolicy = CachePolicy(
ttl = 24.hours,
maxCacheSize = 10.megabytes
)
)
val result = manager.evaluate(
flagKey = "new_payment_flow",
entityID = "user123",
entityContext = mapOf("country" to "US")
)When back online: background sync, incremental updates, conflict resolution, retry logic. Example: SyncPolicy(autoSync = true, syncInterval = 5.minutes, ...).
Preload by usage, by user, background prefetch. Example: PreloadStrategy.INTELLIGENT, preloadFlags, prefetchEnabled.
Strategies: Server wins (default), Client wins, Merge (custom), Last write wins.
Application → Flagent SDK → Cache Manager → Offline Storage → Network sync when online. Flow: start → load from cache → sync if online → update cache → serve from cache.
Kotlin (Android/JVM): AndroidOfflineStorage, SQLiteOfflineStorage. Swift: iOSOfflineStorage. JavaScript: IndexedDBOfflineStorage.
OfflineStorage: save, load, clear, getFlag, updateFlag. FlagentManager: sync, syncInBackground, enableAutoSync, disableAutoSync.
CachePolicy (ttl, maxCacheSize, storageLocation, preloadStrategy, preloadFlags, prefetchEnabled). SyncPolicy (autoSync, syncInterval, syncOnAppStart, syncOnNetworkAvailable, conflictResolution, customMerge). Env: FLAGENT_OFFLINE_STORAGE_*, FLAGENT_CACHE_*, FLAGENT_AUTO_SYNC_*.
Mobile app offline; PWA with IndexedDB; desktop with local cache.
Phase 1: Persistent storage, local cache, TTL. Phase 2: Auto-sync, background sync, incremental updates. Phase 3: Conflict resolution, predictive caching, compression, encryption.