Cloudflare Workers provides a serverless execution environment that allows you to create new applications or augment existing ones without configuring or maintaining infrastructure.
Automatic scaling – Traffic is automatically routed and load balanced across servers.
High-performance global network – Your code is powered by Cloudflare's global network.
No cold starts – Cloudflare supports 0ms cold starts.
For example, use cases of Cloudflare Workers, check out their documentation with various examples.
Cloudflare Workers have different plan limits and restrictions based on your account. Please refer to the official Cloudflare Limit documentation for more information.
This template uses Cloudflare cache API to provide performant caching for the Optimizely Datafile.
Out of the box, Optimizely's Feature Experimentation SDKs require a user-provided identifier to be passed in at runtime to drive experiment and feature flag decisions. This example generates a unique id, stores it in a cookie and reuses it to make the decisions sticky. Alternatively, you can use an existing unique identifier available within your application and pass it in as the value for the
For more information on how Optimizely Feature Experimentation SDKs assign users to feature flags and experiments, see the documentation on how bucketing works.
You must install the Wrangler CLIthis template.
- Generate a project using the template hosted on GitHub:
wrangler generate projectname https://github.com/optimizely/cloudflare-worker-template
wrangler.toml. If you do not know the account ID, type in
wrangler whoamiand you will see the account ID listed.
- Install node nodules.
- Update your Optimizely Feature Experimentation
src/index.js. Your SDK keys can be found in the Optimizely application under Settings.
- Test and debug the worker locally:
- Deploy the worker on Cloudflare:
- Tail the logs for debugging when accessing worker deployed on Cloudflare (optional):
wrangler tail -f pretty
Updated about 1 month ago