Skip to content
Gaurav Tiwari edited this page Aug 27, 2026 · 1 revision

CDN

Rewrites same-site static file URLs to an origin-pull CDN hostname. Independent of Cloudflare — you can run both, one, or neither.

Off by default.

Configure

  1. Point your CDN at your site as an origin-pull source.
  2. Enter its HTTPS hostname under CDN.
  3. Choose the file extensions it should serve.

Defaults: css, js, mjs, jpg, jpeg, png, gif, webp, avif, svg, ico, woff, woff2, ttf, otf, eot.

What gets rewritten

Only same-site URLs with a selected extension, under home_url(), site_url() or content_url(). Everything else is untouched:

  • Third-party URLs
  • HTML routes
  • REST and AJAX responses
  • Any extension you did not select

Root-relative and protocol-relative URLs are both handled.

How it interacts with the page cache

The CDN rewrite runs as the outermost output buffer, started before the page-cache capture. When origin caching is active, the cached HTML already contains rewritten URLs, so a cache hit serves CDN URLs with no extra work. When origin caching is bypassed, CDN delivery still applies. The rewrite is idempotent, so a URL already pointing at the CDN is left alone.

Choosing extensions

Start with fonts and images. Add css and js once you have confirmed the CDN serves correct MIME types and CORS headers — a CDN that drops Access-Control-Allow-Origin will break web fonts specifically, and that failure looks like a font problem rather than a CDN problem.

Related

Cloudflare · Media, Fonts and Embeds

Clone this wiki locally