Cloudflare caching rules can reduce origin traffic and improve response times, but an overly broad rule can serve the wrong HTML, expose personalized content, or make updates appear broken. This guide provides a safe workflow for caching static assets, HTML, APIs, and WordPress pages, then shows what to monitor and when to revisit the configuration.
Overview
Cloudflare sits between visitors and your origin server as a reverse proxy. When a response is cacheable, an edge location can serve a stored copy instead of requesting the resource from the origin on every visit. This is the basic value of edge caching: fewer origin requests, lower latency for distant visitors, and a better chance of maintaining consistent performance during traffic spikes.
The safest Cloudflare cache rules begin with URL and response behavior, not with a blanket instruction to cache everything. A public logo, stylesheet, or versioned JavaScript file has a very different risk profile from a checkout page, account screen, or API response containing user-specific data.
Before creating rules, document your site’s major request types:
- Static assets: CSS, JavaScript, fonts, images, and downloadable files.
- Public HTML: articles, landing pages, documentation, and other identical pages for most visitors.
- Private or transactional pages: login, account, checkout, cart, and admin screens.
- APIs: public read-only endpoints, authenticated endpoints, and write operations.
Then confirm how the origin sets Cache-Control, Set-Cookie, and related headers. A Cloudflare cache rule can influence whether a response is eligible for caching, but it should not replace a clear application-level caching policy. For background on the headers themselves, see the Cache-Control headers guide.
What to track
1. Static asset behavior
Static files are usually the safest starting point. Track cache status for representative CSS, JavaScript, image, and font URLs. A response served from an edge cache should show an appropriate cache status in the response headers, while a miss or bypass should have an identifiable reason when available.
Use long browser and edge lifetimes only when your deployment process changes filenames or query-string versions when content changes. If a file keeps the same URL after every release, a long lifetime can leave visitors with an old asset. Versioning is generally safer than relying on frequent emergency purges; see the guide to cache busting for CSS, JavaScript, and images.
2. HTML cache eligibility
For public HTML, track whether the page is cached, the effective cache lifetime, and how quickly changes become visible after publishing. Start with a small group of pages rather than the entire site. Confirm that the response does not contain a session identifier, account name, cart total, or other visitor-specific value.
If you choose a Cloudflare rule that makes HTML cacheable, exclude paths used for administration, authentication, previews, search results, and other personalized functions. A rule matching every request on a hostname is difficult to audit and can override assumptions made by plugins or application code.
3. WordPress exclusions
A typical WordPress site should keep the administrative area and login flow out of page caching. Common paths to review include /wp-admin/, /wp-login.php, and any custom account, membership, preview, or form-processing paths. WooCommerce sites also need special treatment for cart, checkout, account, and order-related URLs. Exact paths vary by plugins and site architecture, so inspect the actual requests generated by your installation.
Do not assume that a page is safe to cache merely because its URL looks public. Cookies, query parameters, membership logic, geolocation, and A/B testing can all change the response. The WordPress caching guide provides a broader checklist for page cache, object cache, CDN, and WooCommerce behavior.
4. API behavior
For Cloudflare API caching, begin with public, read-only GET responses whose content is the same for all visitors. Avoid caching requests that use authorization credentials, identify a user, modify data, or return private records. Be explicit about which query parameters belong in the cache key; otherwise, two logically different responses may be treated as the same object.
Track freshness requirements, purge behavior, error responses, and origin load. A cached API response that is fast but stale beyond the application’s tolerance is not a successful configuration. Treat API caching as a separate policy from ordinary static-file caching.
Cadence and checkpoints
Review Cloudflare caching rules monthly for active sites and at least quarterly for stable sites. A review does not need to mean changing settings. It means testing whether the rules still match the application.
- After a rule change: Test a cacheable URL, an excluded URL, a logged-out request, and an authenticated request. Check response headers and the page content.
- After a deployment: Confirm that new CSS and JavaScript are available and that old HTML does not reference missing asset versions.
- After a plugin or theme update: Recheck WordPress login, previews, forms, cart, checkout, and account pages.
- Monthly or quarterly: Compare cache hit ratio, origin request volume, response time, purge frequency, and reported stale-content incidents.
- After a migration: Test every hostname and subdomain separately. A rule intended for the public site may unintentionally apply to an API, staging hostname, or media subdomain.
Keep a short change record with the rule expression, purpose, date, expected behavior, and rollback step. Cloudflare’s dashboard labels and available options can change, so verify the current interface and plan-specific capabilities before following an old screenshot or copied configuration.
How to interpret changes
A low cache hit ratio is not automatically a failure. A site with mostly private pages, rapidly changing content, or many unique query strings may have limited cacheable traffic. Interpret the ratio alongside URL mix, traffic volume, cache-control headers, and origin response time. The cache hit ratio troubleshooting guide can help separate normal misses from configuration problems.
If performance improves for static files but HTML remains slow, investigate origin generation time, database work, and uncached application requests rather than broadening the HTML rule immediately. You can also compare edge and origin timing to determine whether the main opportunity is delivery or server processing. See how to improve TTFB for a measurement workflow.
Frequent stale-content complaints usually indicate one of three issues: the freshness window is too long, deployments do not purge or version affected objects, or the cache key does not represent the content variations. Repeated bypasses may indicate cookies, authorization headers, query strings, origin headers, or an exclusion rule. Check the actual request and response before changing the rule.
Most serious problems are content-safety problems, not merely speed problems. If a visitor sees another user’s name, cart, account data, or permissions, disable the relevant cache rule and purge affected objects while investigating. A conservative bypass is preferable to guessing about personalized responses.
When to revisit
Revisit your Cloudflare caching rules on a recurring schedule and whenever the site’s content model changes. The highest-value checkpoints are a new WordPress plugin, a WooCommerce feature, a membership or personalization system, an API release, a domain migration, a change in deployment tooling, or a redesign that changes asset URLs.
Use this practical audit sequence:
- List every hostname and classify it as public site, admin, API, media, staging, or another function.
- Choose one representative URL for static assets, public HTML, private HTML, and API traffic.
- Record cache status, cache-control headers, cookies, query parameters, and response content for each URL.
- Verify that exclusions cover login, administration, cart, checkout, account, preview, and authenticated API paths where applicable.
- Publish a harmless test change, confirm its visibility, and document the correct purge or versioning procedure.
- Review cache hit ratio, origin load, TTFB, and user reports after the change.
Finally, test from both an anonymous session and an authenticated session, using more than one location when possible. Cloudflare caching is safest when each rule has a narrow purpose, an explicit exclusion strategy, and a measurable rollback path. For a broader comparison of edge delivery options, see the CDN comparison for websites.