-
Notifications
You must be signed in to change notification settings - Fork 0
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.
- Point your CDN at your site as an origin-pull source.
- Enter its HTTPS hostname under CDN.
- Choose the file extensions it should serve.
Defaults: css, js, mjs, jpg, jpeg, png, gif, webp, avif, svg, ico, woff, woff2, ttf, otf, eot.
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.
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.
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.
GT Performance · GPL-2.0-or-later · Issues and pull requests welcome
Getting started
Caching
Optimization
Delivery
Operations
Reference