Get the datafile
How to sync 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 syncing a local copy of this datafile, the SDK can run flag rules without making a blocking network request to an outside API, ensuring microsecond latency.
Sync your application with the datafile using the following methods:
-
Pull method (recommended) – In SDKs released in 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 the following 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 the Optimizely servers before initializing a client. For information, see a Optimizely Full Stack (Legacy) version of this documentation.
-
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 sync 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 two seconds. The time depends on the SDK language and version, the sync method, and the local cached copy version. If you are experiencing delays longer than 15 seconds, contact Optimizely Experimentation Support.
Sync across the SDKs
If you prefer not to sync 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 project complete the following:
-
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 displays when accessed from the CDN URL. You can also use this URL to implement your own custom datafile fetching.
Example datafile
For a properly formatted JSON datafile, see Example datafile.
Updated 24 days ago