Skip to content
Media CloudDocs
Happy HolidaysSave 20% with codeValid through December 31Shop the sale
CDN Settings
On this page

CDN Settings

Serve offloaded media through CloudFront, Cloudflare, Bunny, Fastly or another CDN, and invalidate caches when files change.

3 min read·3 tags

If you are not using Imgix, a CDN in front of your storage bucket reduces latency and can reduce egress costs. Media Cloud only needs the CDN’s base URL; the CDN itself is configured with your provider.

CDN Base URL

This is the base URL Media Cloud uses when rewriting image and media URLs. It replaces the storage host, for example:

https://cdn.example.com

Do not include a trailing path unless your CDN serves the bucket from one.

Document CDN Base URL

Use this if non-image files should come from a different CDN or hostname. If left blank, document URLs use the image CDN or the storage URL.

Imgix

When Imgix is enabled, the CDN Base URL is ignored for images; Imgix serves them. The Document CDN Base URL is still used for non-image files.

Common CDN setups

The exact steps depend on the CDN. In general:

  1. Create a distribution or pull zone with your storage bucket as the origin.
  2. Restrict origin access so the bucket is only readable through the CDN, if your provider supports it.
  3. Add a custom domain and enable HTTPS.
  4. Put the custom domain in CDN Base URL.
  5. Purge the CDN after changing files or Media Cloud settings.

Amazon CloudFront

Use the S3 bucket as the origin. Restrict bucket access with an origin access identity or origin access control, and forward the Host header only if your setup requires it. The distribution domain or custom domain goes in CDN Base URL.

Cloudflare

Create a CNAME or custom domain that proxies to the bucket’s public hostname. Keep the proxy enabled and use the custom domain in CDN Base URL. Cloudflare’s cache rules determine how long media is cached.

Bunny CDN

Create a pull zone whose origin is the storage bucket or storage zone. Use the pull zone hostname in CDN Base URL. If the storage provider is Bunny CDN, the pull zone URL is already part of the provider settings.

Fastly

Configure the bucket as the origin and set the CDN hostname in CDN Base URL.

Cache invalidation

When you replace an image or change storage settings, the CDN may keep serving the old file. Invalidate the affected URLs or purge the whole cache.

  • CloudFront: create an invalidation for the changed paths.
  • Cloudflare: purge by URL or purge everything.
  • Bunny: purge the pull zone cache.
  • Fastly: purge by URL or surrogate key.
  • Imgix: use Imgix’s cache controls.

If a new file keeps its old content, check the storage URL directly first. If the storage URL is correct but the CDN URL is stale, the problem is the CDN cache.

HTTPS and mixed content

Use an HTTPS CDN URL on an HTTPS site. An HTTP CDN URL causes mixed-content warnings and may be blocked by the browser.

Troubleshooting

ProblemLikely cause
URLs still use the storage hostCDN Base URL is empty or the CDN is disabled.
Images load from Imgix, not the CDNImgix is enabled; the image CDN setting is ignored by design.
CDN returns 403Origin access is misconfigured, or the bucket is private and the CDN is not authorized.
CDN returns 404The origin path or bucket mapping is wrong.
Old images keep appearingThe CDN cache was not purged.
Mixed-content warningsThe CDN URL is HTTP on an HTTPS site.

Need a hand with this guide?

Send support the exact step you’re stuck on and we’ll help you finish the setup.

Contact support
Start typing to search the docs

Escto close·⌘Kto open

View all results →