How to Configure Cloudflare Caching for Logins, Forms and Ecommerce

How should Cloudflare caching rules be configured for a website with logins, forms or ecommerce pages?

Use separate caching decisions for public and dynamic traffic. Public pages whose responses are the same for different visitors may be cache candidates. Login, account, form-processing, basket, checkout and other personalised or transactional responses should not be forced into the edge cache. If the origin must control caching, remove an Edge TTL override that would overrule it. Check rule scope, cookies and unintended matches such as /cdn-cgi/*, and remember that Cache Rules require the relevant DNS record to be proxied through Cloudflare.

Cloudflare says Cache Rules can adjust what matching requests are eligible to cache, how long they are cached and where they are cached.
Cache Rules · Cloudflare Cache (CDN) docs · As of 2026-11-20
Cloudflare says serving a website homepage and product pages from its cache can eliminate costly database calls and reduce load on origin infrastructure.
Ecommerce websites on Cloudflare: best practices | Cloudflare Blog · As of 2026-11-20
Cloudflare advises removing an Edge TTL override that forces a page to be cached when the origin must control caching.
Dynamic content and login issues · Cloudflare Cache (CDN) docs · As of 2026-11-20
Cloudflare documents a configuration in which it can cache a response and remove the Set-Cookie header before storing that response at the edge.
Dynamic content and login issues · Cloudflare Cache (CDN) docs · As of 2026-11-20
Cloudflare states that Cache Rules require the DNS record for the domain or subdomain to be proxied through Cloudflare.
Cache Rules · Cloudflare Cache (CDN) docs · As of 2026-11-20
Cloudflare advises checking during debugging that rules are not matching Cloudflare-generated paths such as /cdn-cgi/*.
Dynamic content and login issues · Cloudflare Cache (CDN) docs · As of 2026-11-20

Start with page purpose, not one rule for the whole site

Cloudflare says Cache Rules can adjust what matching requests are eligible to cache, how long they are cached and where they are cached. Cloudflare notes that ecommerce websites have dynamic characteristics that must be considered when making the most of caching. Classify each response first: public, repeatable content belongs in one group, while login, account, form-processing, basket, checkout and other personalised responses belong in another.

Sources: Cache Rules · Cloudflare Cache (CDN) docs; Ecommerce websites on Cloudflare: best practices | Cloudflare Blog.

  • Classify by response behaviour, not merely by a URL label.
  • Keep public content and dynamic journeys in separate decision groups.
  • Make each rule narrow enough to explain and test.

Choose public pages that are reasonable cache candidates

Cloudflare says serving a website homepage and product pages from its cache can eliminate costly database calls and reduce load on origin infrastructure. Use that statement as a reason to assess genuinely public, repeatable pages, not as a reason to assume every homepage or product response is safe to cache. For each candidate, check whether different visitors should receive the same response and whether the page participates in a session or transaction journey.

Sources: Ecommerce websites on Cloudflare: best practices | Cloudflare Blog.

  • Begin with public responses intended to be repeatable.
  • Treat a product-page label as a prompt to review behaviour, not proof of cache safety.
  • Expand caching only after verifying the expected visitor experience.

Keep logins, forms and transactions under deliberate control

Cloudflare advises removing an Edge TTL override that forces a page to be cached when the origin must control caching. Apply that boundary to responses involved in sign-in, account access, form processing, baskets, checkout and other personalised or transactional work unless their actual behaviour has been reviewed.

Sources: Dynamic content and login issues · Cloudflare Cache (CDN) docs.

After a change, use the enquiry-testing guide to confirm that form submission and owner notification still complete, rather than relying on a successful page load.

  • Do not force caching where the origin must decide cacheability.
  • Treat login, account and transaction journeys separately from public content.
  • Test a form end to end, including its business outcome.

Cloudflare documents a configuration in which it can cache a response and remove the Set-Cookie header before storing that response at the edge. Review cookie-setting and cookie-dependent responses before enabling a cache rule, especially where a customer must remain signed in or carry transaction state forward. If the expected response depends on a visitor-specific session, keep the route outside forced caching until controlled testing confirms the intended behaviour.

Sources: Dynamic content and login issues · Cloudflare Cache (CDN) docs.

  • Review whether a response sets cookies.
  • Identify journeys that rely on a session or personalised state.
  • Do not treat visible content as proof that the underlying journey is intact.

Choose the control point and build narrowly scoped rules

Cloudflare states that Cache Rules require the DNS record for the domain or subdomain to be proxied through Cloudflare. Cloudflare says additional caching can be enabled through Page Rules or by sending cache headers from the origin. Cloudflare provides Cache Rules templates for common use cases. Choose a narrowly scoped Cache Rule where Cloudflare should control matching requests, or retain origin headers where the origin should express the decision.

Sources: Cache Rules · Cloudflare Cache (CDN) docs; Ecommerce websites on Cloudflare: best practices | Cloudflare Blog.

Before changing live traffic controls, confirm Cloudflare’s current prerequisites in its documentation, use the Cloudflare migration guide to check deliberate zone preparation, and review the SSL and origin-connection boundary.

  • Confirm proxying before relying on Cache Rules.
  • Use the control point that preserves the intended cache decision.
  • Start from a template only after checking its scope against the website.

Review matches and verify the business journeys

Cloudflare advises checking during debugging that rules are not matching Cloudflare-generated paths such as /cdn-cgi/*. Before enabling a rule, review its routes, exclusions, cookie implications, cache controller and rollback decision with the person responsible for the website. Test a public page and each important affected business journey from a clean session, record the result, and broaden the rule only when expected behaviour remains intact.

Sources: Dynamic content and login issues · Cloudflare Cache (CDN) docs.

  • Read the final match as if you were an unintended request.
  • Exclude generated paths from broad matching where appropriate.
  • Test complete customer and staff journeys after each change.

Page-type caching decision and verification gate

Use this decision table to review representative route types before enabling a Cloudflare cache rule. A route label alone does not prove that its response is safe to cache.

Route typeResponse purposeCache decisionBefore enablingVerification
Public, repeatable contentInformation intended to be the same for visitorsReview as a cache candidateConfirm the response is not visitor-specific or part of a transactionLoad the page from a clean session
Login or accountAuthentication or visitor-specific account stateKeep under deliberate origin controlCheck session and cookie dependence; avoid forced Edge TTLSign in, use the account function, then sign out
Form processingSubmission and follow-up actionKeep under deliberate origin control until reviewedCheck cookies and the complete expected form outcomeSubmit a controlled test and confirm the business outcome
Basket or checkoutTransaction state and purchase completionKeep under deliberate origin control until reviewedCheck whether the response varies with visitor or transaction stateRun the intended transaction journey without real customer data
Broad rule or templateA rule intended to cover multiple requestsNarrow the match before enablingConfirm proxied DNS and inspect generated-path matchesTest intended and excluded routes separately

Confirm Cloudflare’s current prerequisites in its documentation before a service-affecting change, keep uncertain dynamic routes out of forced caching, and retain a way to reverse the change if a tested journey fails.

When this is not the right approach: Do not use this framework as a substitute for platform-specific review when a website has unusual personalisation, session handling or transaction logic. If a response is uncertain, leave it out of forced caching until its behaviour is understood and tested.

Another perspective

A site-wide cache rule is not a simpler version of a safe cache strategy. Login, form and transaction responses need separate decisions because their behaviour may depend on the visitor, session or transaction.

What follow-up questions matter most?

Should every page on an ecommerce website be cached?
Start by separating public, repeatable responses from responses that may vary by visitor, session or transaction. Review public content as a cache candidate, but do not force caching for login, account, form-processing, basket or checkout traffic when the origin needs to control the response.
Should I use Cache Rules or origin cache headers?
Use Cache Rules when Cloudflare should control matching requests, and consider origin cache headers where the origin should express cache intent. Cloudflare says Cache Rules require the relevant domain or subdomain DNS record to be proxied through Cloudflare.
Why should I review cookies before caching?
Review whether the response sets or relies on cookies before enabling caching. Cloudflare documents a configuration in which it can remove Set-Cookie before storing a cached response at the edge, so session-dependent journeys need careful review.
What should I do if a login or form fails after a cache change?
Narrow or disable the suspected forced caching rule first, then check its scope, Edge TTL, cookie behaviour and whether it matches unintended paths. Retest one complete user journey from a clean session before expanding caching again.

What steps does this workflow follow?

How to make a safer Cloudflare caching decision

  1. List response types: Group representative routes into public content, login or account, form display or processing, basket or checkout, and other personalised responses.
  2. Assess public candidates: Review whether each public response is repeatable for visitors and whether caching it fits the website's intended behaviour.
  3. Protect dynamic journeys: Where the origin must control caching, remove any Edge TTL override that would force the response into the edge cache.
  4. Review cookie behaviour: Check whether each response sets or depends on cookies before treating it as a cache candidate.
  5. Choose the control point: Confirm the relevant DNS record is proxied before using Cache Rules, or use origin cache headers where origin control is appropriate.
  6. Check scope and test: Inspect rule matches, including unintended generated paths, then test important public and transactional journeys after the change.