Practical guides

Configure HTTP caching without exposing private data

Caching helps only when the reused response is appropriate for the visitor and the time of access. A single policy for every resource can hide an update or expose a personalised response.

Go to the method

Cache: decide per response

Classify responses before choosing a lifetime

Inventory public pages, static assets, API responses, accounts and confirmations. Record whether each changes with the user, language or a parameter. Identify browser, intermediary and CDN caches. An account page should not inherit the policy of a public photograph merely because that policy is easy to apply.

Distinguish freshness from permission to store a response. MDN explains that no-cache requires revalidation, whereas no-store requests no storage. private restricts storage to private caches. A cookie alone does not automatically make a response private.

Plan how an update becomes visible

Write an update rule for each family. For a versioned file, confirm that the new page requests the new URL. For a public page with a stable address, describe revalidation or purging. A long lifetime without a replacement procedure only moves the problem to the next content change.

Choose a practical example: a price correction, opening hours or a replaced document. Record when the origin changes, then inspect a session that has already visited the page. A fresh browser alone does not cover a returning visitor retaining an earlier response.

Test different identities and states

On a test environment, compare an anonymous visit, two distinct accounts, logout and back navigation. Inspect the displayed content and received headers rather than only the hosting configuration. Use synthetic test records instead of real personal documents.

Include relevant language, device, filter and error states. Keep the URL, session state, expected response and result for each test. When personalisation passes through a shared cache, have the infrastructure owner review cache keys and exclusions.

Keep a recovery procedure

Document who can purge the cache, verify its effect and restore a previous configuration. A broad purge may temporarily reduce caching benefits, so prepare a check of essential pages after the operation.

Review the policy when customer accounts, commerce, a language or a CDN is introduced. A useful deliverable is a response–policy–test–owner matrix. A performance score alone establishes neither freshness nor isolation between users.

Primary documentation : MDN — HTTP caching.

Reference documents

Acceptance matrix to adapt to your project

These proposed checks use synthetic cases. Decide the required behaviour with the team, record the result and assign unresolved gaps before release.

Test cases, expected outcomes and useful evidence
CaseExpected outcomeEvidence to retain
Unchanged public pageAdvertised policy and conditional response remain consistent across requests.Headers, validator and status from both requests, with the browser state recorded.
Changed public contentThe corrected version arrives within the defined freshness conditions.Old and new content, request time and received headers.
Two test accountsA personalised response for the first account is never served to the second.Isolated requests and content received by each synthetic account.
Sign out and go backSensitive-screen behaviour matches the documented confidentiality requirement.Complete browser sequence and explicitly recorded limitations.

Frequently asked questions

Are no-cache and no-store equivalent?

No. The first requires validation before reuse; the second requests that the response not be stored. Choose according to the content and caches involved, then test the affected journeys.

Should every resource share one cache lifetime?

A single lifetime ignores differences between versioned public assets, editorial pages, prices and personalised responses. Classify responses, define their update process and test signed-in states before choosing lifetimes.