Get the datafile
How to synchronize your application with the datafile in Optimizely Feature Experimentation.
The datafile is a JSON representation of the current state of flag rules for an environment in your Feature Experimentation project. It contains all the data needed to deliver and track your flag deliveries and experiments. By synchronizing a local copy of this datafile, the SDK can run flag rules without making blocking network requests to an outside API, ensuring microsecond latency.
Synchronize your application with the datafile using the following methods:
-
Pull method (recommended) – In SDKs released August 2019 and later, the SDKs automatically fetch the datafile. The SDKs poll and fetch the latest version of the datafile at whatever frequency you set when you instantiate the SDK.
- Some SDKs provide additional datafile synchronization. See the SDK reference documentation for information on how to initialize synchronously or asynchronously and bundled datafiles.
- For SDK versions released before August 2019, get a local copy of the datafile from our servers before initializing a client. For more information, see a Optimizely Full Stack (Legacy) version of this topic.
-
Push method – Use webhooks to fetch and manage datafiles based on application changes. Use this method alone or in combination with polling if you need faster updates.
-
Customized method – If you want to customize or extend how you access the datafile, you can fetch the datafile using the Optimizely CDN datafile URL.
Tradeoffs
When choosing how you synchronize the datafile, consider the tradeoffs between accuracy and latency. The more frequently your application gets the datafile, the more accurate your application is with the Optimizely Feature Experimentation project environment, but the more latency you generate through network traffic. If you want to centralize your network connections to the datafile, consider using Optimizely Agent.
Datafile refresh rate
The datafile updates when you save changes to your flags in the Optimizely app, and changes are typically reflected in datafile within ~2 seconds. The time depends on the SDK language and version, the synchronization method, and the local cached copy version. If you are experiencing delays longer than 15 seconds, contact Optimizely Experimentation support.
Synchronize across the SDKs
If you prefer not to synchronize each of your SDK instances individually with the Optimizely CDN, you can fetch the datafile through a single instance of the SDK, then pass that to other instances. For an example use case, see Multiple SDK implementations and Sharing the datafile with client SDKs.
Agent microservice endpoint
Fetch the datafile for an Agent microservice instance through the get datafile endpoint.
View the datafile through the app
For troubleshooting purposes, you can view the datafile in the Optimizely app. For secure environments, accessing the datafile in this manner is not supported. Instead, you can access the datafile at initialization, passing the datafile access token for authentication.
To access the datafile for your Full Stack project:
-
Go to Settings > Environments.
-
Click the Datafile URLs for the environment to open the CDN link in a new browser tab or window.
The following image shows how the datafile appears when accessed from the CDN URL in the app. You can also use this URL for implementing your own custom datafile fetching.
Example datafile
See Example datafile to see an example in properly formatted JSON.
Updated about 1 year ago