Asset CDN

The Asset CDN module serves static files (CSS, JavaScript, images, fonts) from a CDN instead of your server. Pages load faster and your server handles fewer requests.

It works with any pull-zone CDN (bunny.net, KeyCDN, CloudFront, and similar): the CDN fetches each file from your server the first time it is requested, then serves it from the edge. MilliCache Pro's job is rewriting the asset URLs in your HTML to point at the CDN hostname.

Already running Edge Cache? Its pull zone fronts your whole site, so your static files are cached at the edge as well. Use the Asset CDN when files should live in a pull zone of their own, or when the site itself is not routed through a CDN.

You find it under Settings → MilliCache → Modules → Asset CDN (Content Delivery group).

Note: The Asset CDN is currently in Beta.

Setup#Copied!

  1. Create a pull zone at your CDN provider that uses this site as its origin.
  2. Enable CORS on the zone so fonts load correctly.
  3. In MilliCache, enter the zone hostname (or a custom domain pointing at it) as the CDN hostname.
  4. Enable the module. Your pages now link static files from the CDN hostname.

That is the whole setup: no files are uploaded or synchronized, the pull zone fetches them on demand.

How It Works#Copied!

The module rewrites URLs in your HTML output: any URL on your own host (or one of the additional hostnames) that points into an included directory and ends in an included extension is switched to the CDN hostname. That covers absolute URLs, protocol-relative URLs, root-relative paths, and even JSON-escaped URLs inside inline scripts. Query strings like ?ver=6.5 pass through untouched, so cache busting keeps working.

The rewrite is designed to cost nothing on cached traffic: it runs just inside MilliCache's page buffer, so on cacheable requests the rewritten HTML is what gets stored. Cache hits are served with CDN URLs already baked in, before WordPress even loads. Uncached front-end requests (including logged-in users) are rewritten on the fly, so every visitor sees consistent URLs.

The admin, feeds, and the Customizer preview are never rewritten.

Settings#Copied!

Setting Default Description
CDN hostname empty Your pull zone hostname, or a custom domain pointing at it. A bare hostname is normalized to https://.
Additional hostnames empty Files on your site's own hostname are always served from the CDN. Add other domains your files are linked under, e.g. www.example.com when the site runs on example.com.
Included directories wp-content, wp-includes Only files in these folders are served from the CDN. * is a wildcard, and regular expressions go between # characters.
Included extensions css, js, png, jpg, jpeg, gif, webp, avif, svg, ico, woff, woff2, ttf, otf, eot, mp4, webm, pdf Only these file types are served from the CDN. * is a wildcard: jp*g matches jpg and jpeg.
Exclusions empty Files matching any of these stay on your server. Plain text matches anywhere in the URL, * is a wildcard (e.g. /uploads/*.svg), and regular expressions go between # characters.

Because CDN URLs are baked into cached pages, changing any of these settings (or toggling the module) clears the page cache so no page keeps serving outdated URLs.

On multisite, the CDN is configured in the Network Admin: one CDN hostname fronts the whole install.

WP-CLI#Copied!

 1wp millicache cdn status

Prints the configured hostname, enabled state, and the current additional-hostname, directory, extension, and exclusion lists.

Notes#Copied!

  • The CDN hostname must differ from your site's hostname; if they match, the module does nothing.
  • Only HTML responses are rewritten. JSON and other response types pass through untouched.
  • Fonts require CORS headers from the CDN; if icon fonts or web fonts fail to load after enabling, check the zone's CORS setting first.
  • The module rewrites asset URLs only. To serve whole pages from the CDN edge, use the Edge Cache module.

Next Steps#Copied!

Last updated: