Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

The availability of features may depend on your plan type. Contact your Customer Success Manager if you have any questions.

Dev guideRecipesAPI ReferenceChangelog
Dev guideAPI ReferenceRecipesChangelogUser GuideGitHubDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

Fetch datafiles

Best practices for fetching datafiles, focusing on accuracy, performance, caching, offline support, and datafile size.

In Optimizely Feature Experimentation, the datafile is a JSON payload that defines your experiments, feature flags, and their corresponding configurations. You must ensure that this file accurately reflects the current state of your feature rollout, but you need to manage the performance trade-offs carefully.

Accuracy and performance

When using Feature Experimentation, it is important to balance accuracy and performance. Keeping the datafile up to date ensures that feature flags and experiments function as expected, but frequent updates can impact application performance. Consider an appropriate refresh strategy that maintains accuracy without causing unnecessary network overhead. The following outline key factors to help you make an informed decision:

  • Accuracy requirement – Keep the datafile current to ensure that your experiments and feature flags are delivered by Feature Experimentation as intended, especially when changes occur frequently or when rolling out experiments.
  • Performance impact – Fetching an updated datafile on every request can increase network traffic and slow down application performance. The more frequently your application requests a new datafile, the more processing time and network latency you incur.
  • Trade-off – Choose a suitable refresh interval that meets your accuracy needs without degrading performance. For example, refresh the datafile at a consistent interval, such as every few minutes, or use a conditional fetch mechanism to update only when changes are detected, for instance, using webhooks.

Caching strategies

Caching strategies help reduce redundant network requests and improve application performance. By storing and managing cached datafiles efficiently, you can minimize latency while ensuring that your application has quick access to the latest configurations. The following outline key caching techniques to help you implement an effective approach:

  • In-memory cache – Store the most recent datafile in memory. This lets your application access the current configuration without repeating network requests during the same session.
  • HTTP cache headers – Set appropriate cache headers on your datafile response to leverage HTTP caching. This helps intermediate proxies or CDN layers serve cached file versions, reducing load times.
  • Cache invalidation – Implement a cache invalidation strategy to ensure you refresh outdated datafiles periodically. This might involve time-based expiration or using version identifiers embedded within the datafile.

Optimize datafile for mobile devices

Mobile applications are more susceptible to network fluctuations or complete offline states. To maintain a consistent user experience, you must have a fallback mechanism. Include a static, embedded datafile within your mobile application. This is a default configuration in case the application fails to fetch an updated datafile due to network issues.

Larger datafiles require more bandwidth and longer download times, which can be problematic on mobile networks or in regions with limited connectivity. After downloading the datafile, your mobile application must parse it. A larger file increases the parsing time and can delay the availability of experiments and feature configurations within your application. To address these challenges, break the datafile into separate projects, letting the application fetch only what is needed based on context.

Best practices summary

Effective datafile management helps maintain performance and reliability. Remember the following when implementing Feature Experimentation:

  • Choose a refresh interval that balances the need for accuracy while minimizing network overhead.
  • Implement multi-layer caching using in-memory and persistent caching strategies and proper HTTP cache controls to reduce unnecessary fetches.
  • Prepare for offline scenarios by having a fallback datafile available, especially for mobile devices, to ensure uninterrupted user experience during network issues.
  • Review and optimize the size of your datafile regularly to prevent it from becoming a bottleneck for application performance.