Cloudflare CDN
Cloudflare can act as a CDN in front of your cloud storage bucket, serving your media files from Cloudflare’s global edge network. WP Media Cloud rewrites all media URLs to use your Cloudflare-proxied domain once configured. There is no Cloudflare CDN API integration in WP Media Cloud — configuration is a URL entry only.
How Cloudflare CDN works with WP Media Cloud#
Cloudflare acts as a reverse proxy. Requests for your media files hit a Cloudflare edge node first. If the file is cached at that edge, Cloudflare serves it immediately. If not, Cloudflare fetches it from your origin bucket, caches it, and serves it. WP Media Cloud rewrites your attachment URLs to point to your Cloudflare domain, so every image and file request goes through Cloudflare rather than directly to your bucket.
Cloudflare R2 with a custom domain#
If you are using Cloudflare R2 as your storage provider, Cloudflare CDN delivery is built in. When you connect a custom domain to your R2 bucket, traffic is automatically routed through Cloudflare’s network. You do not need to configure a separate CDN in WP Media Cloud — the custom domain you enter in the Public URL field on the R2 settings panel is already served through Cloudflare.
See Cloudflare R2 for setup instructions including how to connect a custom domain to your bucket.
Cloudflare CDN in front of another storage provider#
If you are using Amazon S3, Wasabi, Backblaze B2, or another storage provider, you can put Cloudflare in front of your bucket using a Cloudflare Worker or by proxying a subdomain through Cloudflare to your bucket’s public URL. Once you have a Cloudflare-proxied URL that resolves to your bucket, enter it in WP Media Cloud as a custom CDN URL.
To configure this in WP Media Cloud, go to WP Media Cloud > Settings, find the CDN section for your provider, select Custom CDN URL, and enter your Cloudflare-proxied domain. Save settings.
All media URLs will be rewritten to use your Cloudflare domain. Files are cached at the Cloudflare edge on first request and served from cache on subsequent requests.
Cache purging#
WP Media Cloud does not integrate with the Cloudflare Cache API. When you replace a file in WordPress and need Cloudflare to serve the updated version, purge the file from the Cloudflare dashboard under Caching > Configuration > Purge Cache, or use the Cloudflare API to purge specific URLs.
Cache rules for your proxied domain can be configured in the Cloudflare dashboard under your domain’s Caching settings.
Troubleshooting#
CDN URL is not rewriting
Confirm the Cloudflare domain is entered correctly in WP Media Cloud > Settings under the CDN section for your provider. The URL should include https:// and no trailing slash. Save settings and reload a page containing media to confirm.
Files return 404 via the Cloudflare domain
Cloudflare is not routing requests to the correct origin. Confirm your Cloudflare Worker or DNS proxy configuration is pointing to the correct bucket public URL. Test the origin URL directly in a browser before adding the Cloudflare layer.
Files return a cached 404 or stale version
Purge the affected URL from the Cloudflare dashboard. Cloudflare may cache error responses depending on your cache rules. Check your Cloudflare cache settings to confirm error responses are not being cached.
Mixed content warnings
Ensure your Cloudflare SSL setting is set to Full or Full (strict). If Cloudflare is connecting to your origin over HTTP, browsers may flag mixed content on HTTPS pages.