Page Rule Cache TTL precedence over DNS‑level TTL when multiple rules match
0 reputation · 14 Jan 2024, 23:09 UTC
0 reputation · 14 Jan 2024, 23:09 UTC
When a request matches both a DNS‑level Cache TTL setting and one or more Page Rules that also define a Cache TTL, the documentation states that the Page Rule value “takes precedence” for matched requests. However, it does not clarify the resolution order when several Page Rules match the same URL, nor whether the most specific rule, the first rule in the list, or the rule with the highest priority wins.
Understanding this behavior is essential for avoiding stale content delivery after origin updates, especially when surrogate‑key purges or Cache‑Control: private headers are also in play.
32775 reputation · 15 Jan 2024, 03:28 UTC
When multiple Page Rules match the same URL, Cloudflare applies only the highest-priority rule—the one with the lowest priority number. Page Rules do not stack, so settings from lower-priority rules are ignored entirely. The DNS-level TTL is a separate layer that controls resolver caching of the hostname; it never re-applies to an HTTP object after a Page Rule has set an Edge Cache TTL.
A common misconception is that the most specific URL pattern wins. It does not. Priority is explicit and manual. A broad, high-priority rule can silently override a narrower, lower-priority rule. If you expected the longest match to take effect, inspect the priority column in the Page Rules list.
The DNS TTL governs how long recursive resolvers cache the A/AAAA answer for the hostname. For proxied records, Cloudflare returns a short value (often 300 seconds with Auto). Once a request reaches the edge, the HTTP cache decision is made independently by the Page Rule's Edge Cache TTL. The DNS TTL does not expire edge-cached content, and a Page Rule match does not alter the DNS answer.
You can confirm edge behavior from response headers on repeated requests:
cf-cache-status: expect MISS on the first request, then HIT on subsequent requests.age: a rising value proves the object is being served from the edge cache.cache-control: reflects the Browser Cache TTL, not the Edge Cache TTL, so treat it as the client-side policy only.Because Cloudflare does not echo the configured Edge Cache TTL in a response header, the practical confirmation is the MISS→HIT transition and the time until the next EXPIRED or MISS.
Before tuning TTLs, ensure the origin response is edge-cacheable. A Cache-Control: private or no-store header prevents storage in the shared edge cache, and a Page Rule TTL does not override it. Remove or rewrite that header at the origin (or with a Worker) first. Also confirm the hostname is proxied (orange cloud); DNS-only traffic bypasses Cloudflare entirely, so neither Page Rules nor edge TTL apply.
Surrogate-key (Cache-Tag) purges and Page Rule TTL are independent: the tag controls which objects a purge invalidates, while the Edge Cache TTL controls how long an object would otherwise live. Purging by tag does not change the TTL applied to the next fetched object.
Page Rules are legacy. Cloudflare has been migrating cache control to Cache Rules and Configuration Rules, whose evaluation order and combination behavior differ. Before relying on the precedence described above, confirm which engine your zone uses.
One diagnostic detail that changes the recommendation: is your zone still using legacy Page Rules, or has it been migrated to the newer Cache Rules engine? If it is the latter, the evaluation order and setting-combination rules are not identical, and the priority-number model above may not apply.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.