Loading Smiley Hoster
Skip to content

Bypass Cloudflare cache for requests carrying a session cookie

Smiley Hoster Team · · 2 min read
Two panels separate cached public assets from a protected private session.

Cloudflare has announced new controls for responses that vary between requests. Before tuning public variants, establish a simpler boundary: an authenticated session should not accidentally reuse another visitor's cached page.

Sign in to a test copy of the application and inspect outgoing cookies in the browser's network tools. Record the cookie name that accompanies authenticated requests, without copying its secret value into notes or a support ticket.

The name member_session below is invented for this example. WordPress plugins and other applications may use entirely different names. Confirm the relevant marker with the person maintaining the application.

Prepare three independent browser profiles: an anonymous visitor, test account A and test account B. Give the accounts visibly different demonstration names so that an unexpected response is easy to recognize.

List personalized pages that do not carry this cookie too. An anonymous basket or a different session mechanism needs its own analysis. A cookie-based exception is a specific control, not proof that every private response is covered.

2. Add a focused cache bypass

Under Caching, open Cache Rules and create a condition combining the exact hostname with the observed cookie marker. Adapt this example:

Example
(http.host eq "shop.example.com" and http.cookie contains "member_session=")

Select Bypass cache for Cache eligibility. This example performs a substring check against the cookie header, so confirm that the application's real requests match the chosen text.

Review other cache rules that could affect the same traffic. The existence of one correctly named rule is not sufficient evidence of the final behavior when several settings interact.

If private responses might already have been cached, arrange to purge the affected content. Do not assume that editing a policy proves previously stored objects have been removed. Keep the existing configuration available while you validate the replacement.

3. Compare responses across identities

Load the same page repeatedly as A, as B and as the anonymous visitor. Use separate profiles rather than signing in and out in a shared browser session.

Inspect response headers and visible content in the network panel. A private response carrying a HIT cache status needs investigation. Conversely, a single response without HIT does not establish that every personalized page is correctly isolated.

Test deep links, logout and a return to a previously visited page. The acceptance condition is about content: each profile must receive only its own expected state.

Keep this small test matrix with the cache rule. Run it again after a session-cookie change, a relevant plugin update or a new caching policy, because any of those can invalidate the assumptions behind the original match.

Sources: Cloudflare Blog, Cloudflare documentation.

Slide 1 of 5: Cloudflare cache. Keep session content separate. Find the session cookie, focus the bypass, then test across identities.
Slide 2 of 5: Step 1 of 3. Find the real cookie. Inspect authenticated requests in browser network tools. Record the cookie name, never its secret value. Check personalized pages using other session mechanisms separately.
Slide 3 of 5: Step 2 of 3. Create a focused bypass. Match the exact hostname and observed cookie marker in Cache Rules. Select Bypass cache. Review overlapping rules and arrange a purge if private content may already be cached.
Slide 4 of 5: Step 3 of 3. Test separate identities. Use separate profiles for accounts A, B and an anonymous visitor. Repeat page loads, deep links and logout checks. Inspect headers and content: each profile must see only its expected state.
Slide 5 of 5: Validate the boundary. A bypass rule needs testing. One response without HIT is not proof. Keep your test matrix and rerun it after cookie, plugin or cache-policy changes.
On social media

See it in our social posts

The key steps of this article, as a carousel. Follow us to catch the next ones.

Did this article answer your question?
Your feedback shapes what we write next.

Your site online today

Free migration* · 30-day refund

Get started* A site under 30 GB, cPanel, WordPress and VPS plans.