Answer box: Cache public assets and pages only when their contents are safe to share with everyone receiving that cache entry. Keep account summaries, private chats and other personalized responses out of shared page caches. For sensitive responses, use
Cache-Control: private, no-storeand explicit cache-bypass rules. Treat stored AI results as a separate application feature: check authorization before reuse, and separate private results by their verified owner and relevant inputs. HTTP headers alone do not implement application-level access controls. (rfc-editor.org)
The deciding question is not “Was this page written by AI?” It is “Could another visitor safely receive this exact response?” HTTP caching distinguishes shared caches from private caches; it does not create a special category for AI-generated content. (rfc-editor.org)
This guide is for site owners and developers adding AI features to WordPress or custom applications. The examples below are proposed configurations, not measurements or claims about a particular host. Test them on staging before changing production.
1. Map what each cache actually stores
Do not treat “caching enabled” as one setting. WordPress documentation distinguishes browser, object and server caching, while page-cache plugins can save rendered pages as static files. A database-object cache and a cached HTML response therefore need different checks. (developer.wordpress.org)
Start with this conservative classification:
| Content | Suggested starting policy | What to verify |
|---|---|---|
| Public images, CSS and JavaScript | Cache | Files contain no private information; updated files get appropriate versioning |
| Public articles and approved FAQs | Shared caching may be suitable | HTML is identical for the intended audience |
| Public page containing a private AI widget | Cache only the public portion | Neither initial HTML nor embedded data contains personal content |
| Account summaries and private chats | Bypass shared response caching | Authentication, authorization and response headers |
| Login, checkout and session-changing responses | Exclude from initial page-cache rollout | Cookies, redirects and user-specific state |
| AI results stored by the application | Design separately | Ownership, authorization, inputs, expiry and invalidation |
These are rollout recommendations based on the distinction between shared and private responses—not a universal configuration for every platform. Personalized content should not be placed in a shared HTTP cache. Versioned static resources, by contrast, support longer-lived caching without overwriting the same resource URL. (developer.mozilla.org)
Create an inventory of your CDN, host page cache, WordPress plugin, framework cache and application result store. Record which person or setting controls each layer. That inventory becomes your test and rollback checklist.
2. Use Cache-Control correctly—and check overrides
For a sensitive account-summary response, a conservative header is:
Cache-Control: private, no-store
The directives have different meanings:
privateprohibits shared-cache storage but permits private-cache storage.no-storeinstructs HTTP caches not to store the response.no-cachepermits storage but requires validation before reuse.max-agedefines a freshness lifetime.s-maxagedefines freshness for shared caches, overridingmax-agethere. (developer.mozilla.org)
A common mistake is using no-cache when the intention is “do not store this private response.” Another is using private alone while expecting it to prevent browser storage.
Cookies are not a universal safety barrier either. RFC 9111 explicitly notes that Set-Cookie does not itself prohibit caching. Cloudflare documents protective default behavior for such responses, but its behavior depends on configuration. Do not assume the same behavior applies to every CDN or reverse proxy. (rfc-editor.org)
Inspect the effective edge configuration, not just the header generated by your application. Cloudflare Cache Rules can override origin cache controls, including through an Edge TTL setting that ignores the origin header. A broad “cache everything” rule deserves particular scrutiny before enabling account or AI features. (developers.cloudflare.com)
For private routes, combine the origin header with explicit shared-cache bypass rules. Verify both on staging rather than assuming either setting protects every layer.
3. Make cache keys match the response’s real inputs
A cache key determines which requests can reuse an entry. HTTP caches use the request method and target URI as a minimum basis; Vary identifies additional request headers that affect response selection. (rfc-editor.org)
For public content, ask what changes the answer:
- Language or locale?
- A meaningful query parameter?
- Public content version?
- A selected public category?
- Different representations requested through headers?
Do not discard a query parameter merely to improve cache hits. If it changes the answer, deliberately preserve that distinction or bypass caching until the behavior is understood.
Also, do not assume Vary: Cookie makes private shared caching safe. It expresses a variation rule, not authorization. Cloudflare’s documentation says arbitrary Vary values are not considered by default unless the relevant support is configured; there are documented exceptions and settings. (developer.mozilla.org)
AI-result caching needs its own design. As an application-design recommendation, identify everything that makes a stored result valid:
- Public versus private scope.
- Verified tenant and user identity for private results.
- Relevant input and conversation context.
- Prompt, model and source-document versions.
- Locale and output format.
- Expiry and invalidation conditions.
This is a suggested design checklist, not an HTTP-standard key format. Authenticate and authorize the request before returning a cached private result. OWASP recommends checking permissions on every request; a cache hit should not skip that check. (cheatsheetseries.owasp.org)
If you cannot confidently define the ownership boundary, leave private AI-result reuse disabled initially.
4. Worked example: public FAQ versus private account summary
Consider a hypothetical site with two AI-assisted features.
Public FAQ: An editor approves an answer generated from published documentation. Every visitor using the same language and FAQ revision may receive it.
An illustrative response policy is:
Cache-Control: public, max-age=60, s-maxage=300
Under those directives, the response has a 60-second freshness lifetime in a private cache and a 300-second lifetime in a shared cache. These values are examples, not recommended defaults; choose them according to how quickly corrections must become visible. (developer.mozilla.org)
A proposed application result identifier might look like:
faq:public:topic-17:en:documents-v8:prompt-v3
That identifier is explanatory pseudocode. When the source documents or approved answer change, change the version and invalidate the affected page and result entries.
Private account summary: A logged-in user requests a summary of their own account records. Another user requests the same endpoint path.
Use:
Cache-Control: private, no-store
Keep that endpoint outside shared page caching. If internal result reuse is necessary, authorize the requester first and scope the entry to the verified owner, relevant records and generation inputs. The private HTTP response policy and the application authorization check solve different problems. (developer.mozilla.org)
For staging, give the accounts unmistakable fictional markers such as ACCOUNT-A-ONLY and ACCOUNT-B-ONLY. User B must never receive A’s marker, even after A has repeatedly requested the summary.
Finally, inspect the whole response—not just visible text. A public page is not safely shareable if its initial HTML contains a private summary in an embedded data object.
5. Apply exclusions in WordPress, the CDN and the framework
For WordPress, begin with your installed cache plugin’s documented treatment of known users. WP Super Cache’s recommended settings include not caching pages for known users; its documentation defines these as logged-in visitors, commenters and visitors requiring custom per-user data. Other plugins may behave differently. (wordpress.org)
Build an exclusion checklist covering:
- Administrative and login routes.
- Account, cart and checkout routes used by your site.
- Preview responses.
- Private AI endpoints and conversation pages.
- Actual login, membership and session cookies.
- Relevant authorization headers and meaningful query parameters.
This is a starting inventory, not a claim that every WordPress site uses the same routes or cookies. Confirm them in your installed plugins and captured staging requests.
At the CDN, verify that exclusions win over broad caching rules. Cloudflare supports cookie-based bypass rules, and its Cache Rules apply matching settings in order: the last matching value wins when settings conflict. A bypass rule can therefore be undone by a later matching eligibility rule. (developers.cloudflare.com)
For a framework application, check the documentation for your installed version and enabled caching model. Current Next.js documentation states that Route Handlers are not cached by default, but caching can be enabled for GET handlers. That default does not establish what an independently configured CDN or application result store does. (nextjs.org)
Test the deployed staging build, including upstream data caches—not merely the development server or the final response header.
6. Test cross-user isolation with warm caches
Use two separate browser profiles and a third anonymous session. Separate tabs in one profile are unsuitable when they share the same login session.
Run this proposed acceptance sequence with synthetic data:
- Capture the baseline. Save cache settings, response headers and expected account markers.
- Warm as A. Sign in as A and request the private page and endpoint repeatedly.
- Request as B. Open the same URLs in B’s independent session.
- Request anonymously. Confirm that private content is not returned.
- Reverse the order. Warm as B, then repeat as A.
- Test session transitions. Log out, log in again, refresh and navigate back.
- Change inputs. Update a staging source record, locale or public document version.
- Exercise failure paths. Check expired sessions, denied access and controlled staging errors.
These are proposed checks, not evidence that any particular site has passed them. Permission-denied and anonymous requests matter because authorization must be enforced on every request. (cheatsheetseries.owasp.org)
Inspect response bodies alongside headers. On Cloudflare, CF-Cache-Status: HIT means the resource was found in its cache. MISS means it was eligible but absent—not permanently excluded. Explicit bypass rules can produce DYNAMIC, while origin-driven non-cacheability can produce BYPASS. (developers.cloudflare.com)
Repeat ordinary requests with normal browser caching enabled. Do not use only force reloads: browsers commonly send revalidation directives during those requests, which changes what you are testing. (developer.mozilla.org)
A successful test should demonstrate both sides: public content is reusable as intended, while private content remains isolated after repeated requests.
7. Roll back unsafe rules and remove affected entries
Before rollout, save a known-good configuration and document the controls needed to disable each cache layer. Keep current backups before changing application files or server configuration.
If isolation fails on staging:
- Disable the new shared-cache eligibility rules or apply a verified bypass for affected routes.
- Restore the last known-good plugin and framework settings.
- Confirm sensitive responses return the intended private/no-store policy.
- Purge affected CDN and host page-cache entries.
- Invalidate affected application-level AI results separately.
- Repeat the A/B/anonymous tests before re-enabling caching.
Treat rollback and purging as separate tasks. Changing future response headers is not an adequate plan for finding every previously stored variant.
Check your provider’s purge limitations. Cloudflare warns that a dashboard single-file purge may not cover custom cache keys containing headers or cookies, and documents additional limitations for rules matching only GET requests. Use a purge method that covers the actual variants. (developers.cloudflare.com)
For WP Super Cache, its documented removal procedure starts by turning off caching and clearing the cache. Avoid blindly deleting configuration blocks: its documentation warns that plugin-related rewrite sections can also contain WordPress rules. (wordpress.org)
If real users receive someone else’s private information, stop the affected shared caching and involve qualified support. This checklist is not a complete incident-response procedure.
The practical target is simple: reuse public content deliberately, authorize private content every time, and make both behaviors observable in staging.
Read next: How to Stop a Staging Website from Sending Emails, Taking Payments or Running AI Jobs