---
updatedAt: 2026-04-07T10:11:22.000Z
agentTools:
  siteIndex: https://developers.liveramp.com/llms.txt
  projectIndex: https://developers.liveramp.com/authenticatedtraffic-api/v1.0/llms.txt
---

# CDN-Driven Storage

You can use your CDN to store envelopes instead of relying on less-secure client-side storage.

[block:image]
{
  "images": [
    {
      "image": [
        "https://files.readme.io/a814d1f-cf-blog-logo-crop.png",
        "cf-blog-logo-crop.png",
        874,
        261,
        "#b9783b"
      ]
    }
  ]
}
[/block]

We support using [Cloudflare Workers](https://workers.cloudflare.com/) to store the RampID envelope in an HTTP cookie instead of client-side. As some browsers differentiate between client-side (Javascript) and server-side (HTTP) storage for data expiration, leveraging a single approach to store data may help simplify some of your workflows and create more durable identifiers.

[block:api-header]
{
  "title": "Cloudflare Serverless Application"
}
[/block]

**Prerequisites**
Node.js
An enterprise Cloudflare account.

**Setup**
First, `git clone`
Then, run `npm install` in the `ats-cloudflare-serverless` directory.

**Environment variables**
The serverless framework configuration for Cloudflare requires the following parameters:

* Account ID (`CLOUDFLARE_ACCOUNT_ID`) - can be retrieved from Cloudflare dashboard overview page
* Zone ID (`CLOUDFLARE_ZONE_ID`) - can be retrieved from Cloudflare dashboard overview page
* Domain (`CLOUDFLARE_DOMAIN`) - path for domain site where function will be deployed( e.g example-site.com)
* Set Path (`CLOUDFLARE_SET_PATH`) - route to trigger the function to set an HTTP cookie
* Retrieve Path (`CLOUDFLARE_RETRIEVE_PATH`) - route to trigger the function to retrieve an HTTP cookie
* Auth Key (`CLOUDFLARE_AUTH_KEY`) - can be retrieved from Cloudflare dashboard. Go to My Profile -> Scroll down to API Keys -> API Key.
* Auth email (`CLOUDFLARE_AUTH_EMAIL`) - logging email

[block:code]
{
  "codes": [
    {
      "code": "$ CLOUDFLARE_ACCOUNT_ID=999 \\\nCLOUDFLARE_ZONE_ID=999 \\\nCLOUDFLARE_DOMAIN=domain.com \\\nCLOUDFLARE_SET_PATH=set_cookie \\\nCLOUDFLARE_RETRIEVE_PATH=retrieve_cookie \\\nCLOUDFLARE_AUTH_KEY=999 \\\nCLOUDFLARE_AUTH_EMAIL=example@example.com \\\nnpm run deploy",
      "language": "shell",
      "name": "Create Deployment"
    }
  ]
}
[/block]

[block:code]
{
  "codes": [
    {
      "code": "$ CLOUDFLARE_ACCOUNT_ID=999 \\\nCLOUDFLARE_ZONE_ID=999 \\\nCLOUDFLARE_DOMAIN=domain.com \\\nCLOUDFLARE_SET_PATH=set_cookie \\\nCLOUDFLARE_RETRIEVE_PATH=retrieve_cookie \\\nCLOUDFLARE_AUTH_KEY=999 \\\nCLOUDFLARE_AUTH_EMAIL=example@example.com \\\nnpm run remove",
      "language": "shell",
      "name": "Remove Deployment"
    }
  ]
}
[/block]

[block:api-header]
{
  "title": "ats.js Cloudflare Configuration"
}
[/block]

Once you have spun up your CDN "backend" in Cloudflare, you will need to configure the client-side version of ats.js to make use of the Workers. There are several configuration parameters to pay attention to:

`useCloudFlare`: a boolean to indicate whether or not the Cloudflare backend should be used. If `true`, populate the parameters below.
`setCookiePathCloudFlare`: The absolute path to set envelopes as HTTP cookies as defined by the `CLOUDFLARE_SET_PATH` serverless variable.
`retrieveCookiePathCloudFlare`: The absolute path to read envelopes from HTTP cookies as defined by the `CLOUDFLARE_RETRIEVE_PATH` serverless variable. This will be used in `ats.retrieveEnvelope` calls.
`cookieAgeCloudFlare`: Cookie lifespan in milliseconds. We recommend `2592000000` (30 days) to match envelope expiration.

[block:code]
{
  "codes": [
    {
      "code": "  {\n    \"logging\":\"debug\", \n    \"placementID\":9999, \n    \"email\":\"imeyers@liveramp.com\",\n    \"useCloudFlare\": true,\n    \"setCookiePathCloudFlare\": 'https://liveramp.com/set_cookie',\n    \"retrieveCookiePathCloudFlare\": 'https://liveramp.com/retrieve_cookie',\n    \"cookieAgeCloudFlare\": 2592000000\n  }",
      "language": "json",
      "name": "Example ats.js Cloudflare Configuration"
    }
  ]
}
[/block]

[block:api-header]
{
  "title": "Other CDNs"
}
[/block]

Not using Cloudflare? We're working on it! Drop us a line at <ats@liveramp.com> with information on your preferred CDN and implementation.