brash-afternoon-80519
03/25/2026, 3:22 AMpowerful-spoon-16837
03/25/2026, 8:52 AMpowerful-spoon-16837
03/26/2026, 11:27 AMrefreshCache() which makes an HTTP GET to /api/features/{clientKey} before opening the SSE connection. The SDK does have a TTL-based cache internally, but the TTL is held in memory and resets to nil on each new SDK instance. So on every app launch or new login session, the cache is always considered expired, and a full network fetch fires regardless of the ttlSeconds value.
What you can do right now:
In the latest SDK version (1.1.0), Offline Mode was added. If you pass a pre-fetched features payload via the features parameter in the builder, the SDK will skip the network fetch entirely at init:
let cachedPayload: Data = ... // from UserDefaults, file cache, etc.
GrowthBookBuilder(
apiHost: "<https://cdn.growthbook.io>",
clientKey: "sdk-abc123",
attributes: userAttributes,
features: cachedPayload,
trackingCallback: { _, _ in },
backgroundSync: true
).initializer()
This eliminates the init-time CDN request. You'd need to persist the payload on your side (e.g., save it to UserDefaults or a file when it arrives via SSE or refreshCache, then pass it back on next init).
If you want to minimize CDN requests even further, you can also set backgroundSync: false and call refreshCache() manually at a cadence that works for you - this gives you full control over when network requests happenbrash-afternoon-80519
03/26/2026, 10:59 PMbrash-afternoon-80519
03/26/2026, 11:15 PMpowerful-spoon-16837
03/27/2026, 2:35 PMrefreshCache() or enable backgroundSync, the SDK will keep working with that preloaded data.
1. If you call refreshCache() or SSE sends new data, the SDK will update and cache the new features.
2. If you close the client, the SSE connection is also closed. No updates will be received while the client is closed - the SDK persists whatever was cached before closing.
3. When you initialize again, there are two options:
a. With preloaded features - the SDK uses them immediately without a network request. But any changes that happened while the client was closed will be missed until the next change occurs in the console. To avoid this, call refreshCache() after init.
4. Without preloaded features - the SDK always makes a GET request to fetch the current state from the server, so you're guaranteed to have up-to-date features.brash-afternoon-80519
03/29/2026, 11:07 PM