Skip to content

Configure Network Settings

⏱ 20 minutes advanced

The Optimizely SDK communicates with two endpoints: the CDN for datafile downloads and the event API for tracking data. Default settings work for most deployments, but regulated environments, high-traffic applications, and edge deployments require tuning polling intervals, routing through proxies, or self-hosting assets. Misconfigured network settings can cause stale flags, dropped events, or unnecessary bandwidth consumption.

  1. Configure datafile polling intervals
  2. Set custom CDN endpoints or proxy URLs
  3. Configure event dispatch settings
  4. Set up firewall allowlists

The SDK periodically fetches the datafile to pick up flag changes. The default interval is 5 minutes. Shorten it for faster propagation or lengthen it to reduce bandwidth.

Set polling interval
javascript
const optimizely = createInstance({
  sdkKey: 'YOUR_SDK_KEY',
  datafileOptions: {
    autoUpdate: true,
    updateInterval: 30_000,  // 30 seconds (minimum: 1000ms)
  },
});
python
from optimizely.config_manager import PollingConfigManager

config_manager = PollingConfigManager(
    sdk_key='YOUR_SDK_KEY',
    update_interval=30,   # 30 seconds
)

client = optimizely.Optimizely(config_manager=config_manager)
csharp
var configManager = new HttpProjectConfigManager.Builder()
    .WithSdkKey("YOUR_SDK_KEY")
    .WithPollingInterval(TimeSpan.FromSeconds(30))
    .Build();

var optimizely = new Optimizely(configManager);
EnvironmentRecommended intervalRationale
Development10-30 secondsFast iteration while building
Production (standard)1-5 minutesBalance freshness with bandwidth
Production (high traffic)5-15 minutesReduce CDN requests at scale
Edge / serverlessDisable polling; use webhooksFunctions are short-lived; polling wastes resources

Feature Experimentation: custom datafile URL

Section titled “Feature Experimentation: custom datafile URL”

Route datafile downloads through a proxy or internal CDN mirror. Use the urlTemplate option with %s as a placeholder for the SDK key.

Custom datafile endpoint
javascript
const optimizely = createInstance({
  sdkKey: 'YOUR_SDK_KEY',
  datafileOptions: {
    autoUpdate: true,
    updateInterval: 60_000,
    urlTemplate: 'https://cdn-proxy.internal.example.com/optimizely/%s.json',
  },
});
python
config_manager = PollingConfigManager(
    sdk_key='YOUR_SDK_KEY',
    update_interval=60,
    url_template='https://cdn-proxy.internal.example.com/optimizely/{sdk_key}.json',
)

client = optimizely.Optimizely(config_manager=config_manager)
csharp
var configManager = new HttpProjectConfigManager.Builder()
    .WithSdkKey("YOUR_SDK_KEY")
    .WithUrl("https://cdn-proxy.internal.example.com/optimizely/YOUR_SDK_KEY.json")
    .WithPollingInterval(TimeSpan.FromSeconds(60))
    .Build();

var optimizely = new Optimizely(configManager);

Route events through a proxy if your firewall blocks direct access to the Optimizely event API.

Custom event dispatcher
javascript
import { createInstance } from '@optimizely/optimizely-sdk';

const optimizely = createInstance({
  sdkKey: 'YOUR_SDK_KEY',
  eventDispatcher: {
    dispatchEvent(event) {
      // Route through your proxy
      const proxyUrl = event.url.replace(
        'https://logx.optimizely.com',
        'https://events-proxy.internal.example.com'
      );
      return fetch(proxyUrl, {
        method: event.httpVerb,
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify(event.params),
      });
    },
  },
});
python
from optimizely.event_dispatcher import EventDispatcher as BaseDispatcher
import requests

class ProxyEventDispatcher(BaseDispatcher):
    def dispatch_event(self, event):
        proxy_url = event.url.replace(
            'https://logx.optimizely.com',
            'https://events-proxy.internal.example.com'
        )
        requests.post(proxy_url, json=event.params, timeout=10)

client = optimizely.Optimizely(
    sdk_key='YOUR_SDK_KEY',
    event_dispatcher=ProxyEventDispatcher(),
)
csharp
// Implement IEventDispatcher to route through a proxy
public class ProxyEventDispatcher : IEventDispatcher
{
    private readonly HttpClient _client = new();

    public void DispatchEvent(LogEvent logEvent)
    {
        var proxyUrl = logEvent.Url.Replace(
            "https://logx.optimizely.com",
            "https://events-proxy.internal.example.com"
        );
        var content = new StringContent(
            JsonSerializer.Serialize(logEvent.Params),
            Encoding.UTF8, "application/json"
        );
        _client.PostAsync(proxyUrl, content).Wait();
    }
}

The SDK batches events to reduce network overhead. Tune batch size and flush interval based on your traffic volume.

Event batching configuration
javascript
const optimizely = createInstance({
  sdkKey: 'YOUR_SDK_KEY',
  eventBatchSize: 50,        // Flush after 50 events
  eventFlushInterval: 5000,  // Or every 5 seconds, whichever comes first
});
python
from optimizely.event.event_processor import BatchEventProcessor

event_processor = BatchEventProcessor(
    event_dispatcher=optimizely.event_dispatcher.EventDispatcher(),
    batch_size=50,
    flush_interval=5,  # seconds
)

client = optimizely.Optimizely(
    sdk_key='YOUR_SDK_KEY',
    event_processor=event_processor,
)
csharp
var eventProcessor = new BatchEventProcessor.Builder()
    .WithMaxBatchSize(50)
    .WithFlushInterval(TimeSpan.FromSeconds(5))
    .Build();

var optimizely = new Optimizely(
    configManager,
    eventProcessor
);

If your infrastructure restricts outbound traffic, allow these endpoints:

EndpointPurposeProtocol
cdn.optimizely.comDatafile downloadsHTTPS (443)
logx.optimizely.comEvent tracking APIHTTPS (443)
*.optimizely.comWildcard (simplest rule)HTTPS (443)
IssueCauseFix
Datafile never updatesFirewall blocking CDNAdd cdn.optimizely.com to allowlist
Events not deliveredProxy rejecting POST requestsVerify proxy passes POST with JSON body
High bandwidth usagePolling interval too shortIncrease to 5+ minutes for production
Stale flag valuesPolling disabled or webhook not configuredEnable autoUpdate or set up webhook triggers