Cloudflare Cache Rules with Multiple Subdomains on a Single WordPress Site β
Super Page Cache automatically creates and manages Cloudflare Cache Rules when you enable Cloudflare CDN & Caching. If your single WordPress installation serves multiple subdomains (for example, www.example.com and blog.example.com), you will notice that the plugin only maintains cache rules for the most recently configured hostname. This article explains why this happens and how to work around it.
π Note: This article covers a single WordPress installation serving multiple subdomains β for example, via URL rewriting or a reverse proxy. If you are running a WordPress Multisite network, see WordPress Multisite (Subdomain Mode) Setup with Cloudflare instead.
Why Cache Rules Are Overwritten β
When you save the plugin settings or re-run the Cloudflare configuration wizard, Super Page Cache automatically updates the Cloudflare Cache Rule for your site to match the currently configured hostname. The plugin is designed to manage a single primary hostname per WordPress installation.
This means:
- The plugin creates or updates one Cache Rule scoped to the current site's hostname.
- If you reconfigure the plugin with a different hostname, the existing Cache Rule is overwritten to match the new hostname only.
- Any subdomains that were previously covered by the rule are no longer included.
As a result, only the most recently configured hostname benefits from Cloudflare edge caching through the plugin's managed rule.
β οΈ Important: This is by design. Super Page Cache does not support managing cache rules for multiple hostnames from a single WordPress install. The workaround below requires manual steps inside the Cloudflare dashboard.
Workaround: Manually Duplicate Cache Rules in Cloudflare β
To ensure all your subdomains are covered by Cloudflare caching, you can manually create additional Cache Rules in the Cloudflare dashboard β one for each subdomain that is not covered by the plugin-managed rule.
Step 1 β Identify the Plugin-Created Cache Rule β
- Log in to your Cloudflare dashboard.
- Select your domain zone (e.g.,
example.com). - Go to Caching β Cache Rules.
- Look for the rule created by Super Page Cache. It is typically named after the plugin and targets your primary hostname (e.g.,
www.example.com).
[Screenshot: Cloudflare Cache Rules list showing the plugin-created rule for the primary hostname]
Step 2 β Create a Duplicate Rule for Each Additional Subdomain β
For each subdomain not covered by the plugin-managed rule:
- On the Cache Rules page, click Create rule.
- Give the rule a descriptive name (e.g.,
SPC β blog.example.com). - Under When incoming requests matchβ¦, set the condition:
- Field:
Hostname - Operator:
equals - Value: your subdomain (e.g.,
blog.example.com)
- Field:
- Under Then the settings areβ¦, configure the cache behavior to match the plugin-created rule:
- Eligible for cache: Enabled
- Set any additional cache settings (e.g., Edge TTL, Browser TTL) to mirror the values in the plugin-managed rule.
- Click Deploy.
- Repeat for each additional subdomain.
[Screenshot: Cloudflare Cache Rule creation form with Hostname equals blog.example.com and cache enabled]
π‘ Tip: Open the plugin-managed rule and the new rule side by side in your Cloudflare dashboard to make sure all settings match. This ensures consistent caching behavior across all subdomains.
Step 3 β Verify the Rules Are Active β
After creating the rules, confirm they are enabled:
- On the Cache Rules page, make sure each new rule shows a green Active status.
- Check that the rules are ordered correctly β more specific hostname rules should not be overridden by broader rules earlier in the list.
Cache Purging Behavior β
Super Page Cache's automatic cache purging is tied to the primary hostname configured in the plugin settings. This affects how purges work across your subdomains:
| Purge type | Primary hostname | Additional subdomains (manual rules) |
|---|---|---|
| Automatic URL purge (on content update) | β Handled by the plugin | β Not handled automatically |
| Purge All (from plugin dashboard) | β Purges the entire zone | β Purges the entire zone (same zone) |
| Manual URL purge (from Cloudflare dashboard) | β Works if the rule matches | β Works if the rule matches |
Because automatic URL-specific purges only fire for the primary hostname, cached pages on additional subdomains will not be purged when you update content. You will need to purge those subdomains manually.
How to Manually Purge Cache for Additional Subdomains β
- In the Cloudflare dashboard, go to Caching β Configuration.
- Under Purge Cache, choose Custom Purge.
- Enter the specific URLs on your additional subdomain that need to be purged (e.g.,
https://blog.example.com/my-updated-post/). - Click Purge.
Alternatively, use Purge Everything to clear the cache for the entire zone, which includes all subdomains. Be aware this will also clear the cache for your primary hostname.
β οΈ Note: Purge Everything clears the Cloudflare cache for the entire zone and all subdomains at once. Use it only when you need to clear all cached content across all subdomains simultaneously.
Verifying Cache Is Working for Each Subdomain β
After setting up the manual Cache Rules, test each subdomain individually:
- Open the subdomain in an Incognito/Private browser window (e.g.,
https://blog.example.com/). - Press F12 to open Developer Tools and go to the Network tab.
- Reload the page and select the first request for your subdomain.
- Check the response headers for
CF-Cache-Status:HITβ Cloudflare is serving the cached page βMISSβ the page was not in cache (normal on first visit; reload to confirm it becomesHIT)BYPASSβ the cache rule is not matching or caching is bypassed for this request
Repeat this check for each subdomain to confirm all Cache Rules are working.
Best Practices and Alternatives β
If managing manual Cache Rules becomes difficult to maintain, consider these alternatives:
- Use a WordPress Multisite network β With Multisite in subdomain mode, each subsite can have its own plugin configuration, and cache rules, purging, and settings are managed independently per subsite. See WordPress Multisite (Subdomain Mode) Setup with Cloudflare for setup instructions.
- Use separate WordPress installations per subdomain β Each install manages its own Cloudflare Cache Rules and purging independently, without any conflicts.
- Use a Cloudflare wildcard Cache Rule β If all your subdomains need the same cache behavior, you can create a single Cache Rule in Cloudflare using a wildcard hostname match (e.g.,
*.example.com). This covers all subdomains at once, although the plugin will still manage its own rule separately.
π Note: A wildcard Cache Rule created manually in Cloudflare will not be overwritten by the plugin. Only the plugin-managed rule is updated when you reconfigure Super Page Cache.
