> For the complete documentation index, see [llms.txt](https://mercure-technologies.gitbook.io/xprem/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mercure-technologies.gitbook.io/xprem/cdn/overview.md).

# Overview

A CDN delivers update assets closer to each application. It improves download latency and reduces traffic on the origin storage.

Without a CDN, the server streams every asset itself, reading it from the configured storage — clients never contact the bucket. With a CDN, the server returns CDN URLs for those assets instead. The CDN retrieves an asset from the origin when needed, then serves cached copies to applications.

### Why use a CDN?

Use a CDN to:

* Reduce asset download latency for globally distributed users.
* Reduce requests and bandwidth consumption on your storage backend.
* Scale asset delivery independently from the OTA server and storage.

The CDN only serves published update assets. Storage remains the source of truth for updates.

### Asset delivery

xprem supports CloudFront, GCS and Azure signed URL delivery, and a generic CDN base URL for public bucket assets.

#### CloudFront

Configure CloudFront with your storage backend as its origin. xprem then returns CloudFront URLs for update assets.

See [CloudFront](/xprem/cdn/cloudfront.md) to configure it.

#### GCS signed URLs

GCS requires no additional CDN configuration.

Set `STORAGE_MODE=gcs`, `GCS_BUCKET_NAME`, and `GOOGLE_APPLICATION_CREDENTIALS_B64`.

The server redirects asset requests to signed GCS URLs. Each URL remains valid for 15 minutes.

Clients download assets directly from Google. The bucket remains private.

CloudFront takes precedence when its domain, key pair ID, and private key are configured, and so does an explicitly configured generic CDN base URL: see [Generic CDN](/xprem/cdn/generic-cdn.md).

See [Google Cloud Storage](/xprem/storage/google-cloud-storage.md) to configure GCS.

#### Azure SAS URLs

Azure requires no additional CDN configuration either.

Set `STORAGE_MODE=azure` with its account variables and the server redirects asset requests to signed SAS URLs. Each URL remains valid for 15 minutes, and the container remains private.

CloudFront and an explicitly configured generic CDN base URL both take precedence over SAS delivery.

See [Azure Blob Storage](/xprem/storage/azure-blob-storage.md) to configure it.

#### S3 direct CDN

S3 direct CDN is the default for `STORAGE_MODE=s3`. It applies when neither CloudFront nor a generic CDN is configured.

xprem returns pre-signed S3 URLs for each asset. Clients download directly from the bucket, which remains private. Each URL is valid for 15 minutes.

To stream assets through xprem server instead, set:

```dotenv
DISABLE_S3_DIRECT_CDN=true
```

Use this when your S3-compatible provider does not support pre-signed URLs. Every asset byte then passes through your server, so size it accordingly.

See [S3 Storage](/xprem/storage/s3-storage.md) for S3 and S3-compatible storage configuration.

#### Generic CDN

Any CDN or accelerated domain in front of a public S3, GCS or Azure bucket works without provider-specific integration.

Set `CDN_BASE_URL` and the server redirects asset requests to that domain.

This is also the path for Cloudflare in front of an R2 bucket, since R2 runs through the `s3` storage mode, and for Azure Front Door in front of a public container: the [Generic CDN](/xprem/cdn/generic-cdn.md) page walks through those setups.

Assets must be publicly readable through the CDN — use CloudFront for private delivery.

See [Generic CDN](/xprem/cdn/generic-cdn.md) to configure it.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://mercure-technologies.gitbook.io/xprem/cdn/overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
