Cloudflare
Cloudflare Edge-side personalization
You can use Cloudflare to classify visitors and execute personalization instructions on the edge. This approach gives you the user experience benefits of server-side rendering with the performance and scalability benefits of a CDN.
tip
For more information about the benefits of executing personalization using Akamai EdgeWorkers, see the overview of edge-side personalization.
Before you start
You must have the following available to complete the instructions in this section:
- Administrator access to Cloudflare Dashboard. You can use their free tier if you don't have an account.
- Ability to clone a GitHub repository.
- Node.js v16+ installed locally.
- An application with edge-side personalization activated.
- Npm access token from Uniform. Edge-side personalization requires private packages. If you don't have an access token, contact us.
Configure CLI#
Cloudflare Wrangler is a CLI enables you to send commands to Cloudflare without having to log into the Cloudflare dashboard. Entering commands on the CLI is faster than having to navigate through a lot of different screens in the dashboard.
- Install Wrangler.
- Authenticate to Cloudflare.
Next steps
Now you are ready to create the Cloudflare Worker, which is the component that executes the personalization instructions exposed by your front-end application.
Write Cloudflare Worker code#
You have two options for writing the Cloudflare Worker. You can build it from scratch or use a functional example provided by Uniform.
Configure Cloudflare Worker#
Create a file
.env
with the following environment variables:Variable name Value UNIFORM_PROJECT_ID
The Uniform project whose manifest is retrieved. UNIFORM_API_KEY
The Uniform API key used to retrieve the manifest. In the file
wrangler.toml
, you must set the value foraccount_id
. This must match your Cloudflare account ID You can retrieve this value by entering the following command on the CLI:In the file
wrangler.toml
, you must set an environment variable to identify the origin (such as the web server that's hosting your front-end application). You must add a new section to the file:About this step
While the variable name suggests this value should be a URL, it really must be the host name for the origin. For example, if the origin is located at
https://some-origin.com
, the value should besome-origin.com
.
Run Cloudflare Worker locally#
You can use Wrangler to run the Cloudflare Worker locally. This enables you to test and debug without having to deploy to Cloudflare.
Enter the following command on the CLI:
About this step
This starts a local web server that hosts the Cloudflare Worker.
Open your browser to the endpoint shown in the console.
Deploy Cloudflare Worker#
Enter the following commands on the CLI:
About this step
These commands build and publish your Cloudflare Worker to Cloudflare.
Next steps
Now that you have Cloudflare delivering edge-side personalization, you might want to take advantage of another feature available when you run personalization on Cloudflare: location-based personalization.