STATUS IS UPWEBSITE OPTIMIZATION WIKI
20Accelerate
Performance and delivery / Accelerate

Browser Caching Guide for Website Owners

Set clear HTTP cache rules so repeat visits avoid needless downloads without trapping visitors on old pages or unsafe personalized content.

Browser Caching Guide for Website Owners — VISUAL GUIDE
READ
7 minutes
SOURCES
6
REVALIDATE
2027-03-27
reviewed
Web performance and release engineering reviewer
THE SHORT ANSWER

Start with the decision.

Use a different caching rule for each kind of URL. Give files whose contents never change at that URL, such as hash-named JavaScript, CSS, fonts, and images, a long freshness lifetime. Give HTML and other unversioned responses a policy that makes the browser validate before reuse when freshness matters. Publish a new asset URL whenever an asset changes; a long cache lifetime cannot reliably be undone for copies that are still fresh.

Start with explicit Cache-Control headers, then verify the headers and browser behavior in a staging environment. Pair validation-friendly responses with ETag and, where available, Last-Modified. Treat personalized, account, checkout, and sensitive responses separately from public pages. SIU uses this work as proactive uptime optimization: it reduces avoidable origin work and prevents cache-related release defects before they disrupt a usable website.

VISUAL GUIDE

See the work as a system.

Use this map to connect the article’s decisions before acting on individual tactics.

SIUAccelerate
01Map the policy to the resource, not the server
02Use Cache-Control terms precisely
03Version immutable assets before assigning a long lifetime
04Make HTML current through validation, not long caching
01

Map the policy to the resource, not the server

Inventory representative URLs before changing headers: a home page, content page, application shell, CSS, JavaScript, images, fonts, APIs, login, account, checkout, and downloads. For each, record whether the response is public or personalized, whether its URL changes when its bytes change, and how fast a correction must reach visitors.

Make a policy matrix from that inventory. A public content-addressed asset needs a different rule from HTML at a stable address. Responses without Cache-Control can still be cached heuristically, so explicit rules are easier to test.

Freshness lifetime

The period a stored response may be reused; max-age gives it in seconds.

02

Use Cache-Control terms precisely

Cache-Control tells browsers and shared caches how to store and reuse a response. max-age=N permits reuse while fresh. s-maxage=N sets shared-cache freshness and overrides max-age there, but browsers ignore s-maxage. public permits any cache; private permits browser caching but prevents shared-cache storage.

no-cache permits storage but requires origin validation before reuse. no-store means caches must not store the response, but is not a complete privacy control. Use must-revalidate when serving stale content after expiry is unacceptable; an unavailable origin can then yield a 504 rather than a stale fallback.

Avoid blanket no-store

It removes storage rather than merely requiring a check; reserve it for responses that genuinely must not be stored.

03

Version immutable assets before assigning a long lifetime

A versioned asset URL includes a content fingerprint or release version, such as app.4f2c.js. When asset bytes change, publish a different URL and update the HTML reference. The cache sees a new resource, so visitors fetch the new asset without an invalidation reaching every browser.

For a representation that will not change during its freshness lifetime, Cache-Control: max-age=31536000, immutable is a practical pattern. immutable tells supporting clients not to conditionally revalidate while fresh. Do not apply it or a year-long max-age to a mutable same-URL file. Retain prior fingerprinted assets while cached HTML can still reference them.

HTML is the manifest

HTML chooses asset URLs, so release sequencing must retain the referenced generation.

04

Make HTML current through validation, not long caching

HTML usually has a stable, human-facing URL and changes with content, asset references, feature flags, or security notices. A conservative public HTML pattern is Cache-Control: no-cache with ETag and Last-Modified when your platform can produce them correctly. The browser stores the body but uses a conditional request before reuse; an unchanged response can return 304 Not Modified without a body.

ETag identifies a resource version. On a stale response, the browser can send it in If-None-Match; if it matches, the server replies 304, otherwise it sends the new representation. RFC guidance prefers both ETag and Last-Modified on a 200 response when possible. no-cache does not promise validation on Back or Forward navigation because a browser may restore a session-history snapshot.

Validator quality

An ETag must change when the representation changes; test it across origins and deployments.

05

Separate public delivery from personalized and sensitive responses

A shared cache, such as a CDN, may reuse one response for multiple users. Do not let it reuse account-specific HTML or API data across users. For personalized content that may live in a browser, private, no-cache is a sensible starting point: it prevents shared storage and requires validation. A Set-Cookie header alone does not stop caching.

For responses that should not be stored, use no-store and review application code, CDN rules, service workers, browser storage, logs, and error pages. Headers alone are not a privacy, compliance, or payment-security program. Have qualified security, privacy, and payment reviewers assess sensitive flows and applicable requirements.

Authorization changes

Test sign-in, sign-out, account switching, and permission changes with warm browser and CDN caches.

06

Roll out cache changes as a reversible release

Capture baseline headers and body behavior for uncached and repeat requests. In staging, deploy versioned assets first, then HTML that references them, and test older cached HTML against the new origin. Check direct-origin and CDN paths if both exist. DevTools Network headers should show the intended policy and repeat behavior.

Keep a release manifest of asset URLs, header rules, and configuration version. If a release combines incompatible client files, restore compatible HTML and application behavior, but do not overwrite a published fingerprinted file. Repoint HTML to the known-good generation and retain both generations while cached HTML may request them. A shared-cache purge cannot force browsers to discard a fresh response.

Proactive remediation

Turn header-test failures, asset 404s, and version mismatches into changes to the next release checklist.

ACTION / VERIFY

Your practical to-do guide.

  1. 01

    Inventory response classes

    Classify sample URLs as public or personalized, mutable or versioned.

    VERIFY: Includes HTML, assets, APIs, authentication, account, checkout, and errors.
  2. 02

    Capture current headers

    Record Cache-Control, ETag, Last-Modified, Age, Vary, and status at origin and CDN.

    VERIFY: A pre-change snapshot exists for each sample.
  3. 03

    Fingerprint mutable assets

    Make the build publish a new asset URL when its bytes change.

    VERIFY: A changed asset produces a changed URL and HTML reference.
  4. 04

    Set explicit policies

    Use long-lived rules only for immutable versioned URLs; use validation-first rules for stable URLs.

    VERIFY: Header tests match the intended policy.
  5. 05

    Test validation

    Check an unchanged document returns 304 after a conditional request and a changed one returns 200 with a new ETag.

    VERIFY: Staging traces show both paths.
  6. 06

    Exercise privacy boundaries

    Test two accounts, sign-out, role changes, and sensitive routes with warm caches.

    VERIFY: No personalized response crosses users.
  7. 07

    Prove release compatibility

    Load cached prior HTML after the next release.

    VERIFY: Prior and current HTML load their referenced assets without 404s or script errors.
  8. 08

    Document rollback

    Record the good generation, header version, owner, and old-asset retention period.

    VERIFY: A non-production drill restores the known-good generation without editing an immutable URL.
DISCUSSION TOPICS

Compare the trade-offs, not private data.

Use these prompts with your team or website-owner community. Share methods and lessons, but never paste credentials, customer records, or non-public infrastructure details.

  1. 01

    Which URL classes on your site are hardest to classify as public, personalized, immutable, or frequently changing, and how are you documenting the decision?

  2. 02

    What release sequencing test has been most useful for catching an old-HTML and new-asset mismatch before a visitor encounters it?

  3. 03

    Where do your CDN, application, and browser cache rules overlap, and who owns verifying that their combined behavior matches the intended policy?

POPULAR / AUTHORITATIVE RESOURCES

Open the source material.

IETFRFC 9111: HTTP Caching ↗

Explains freshness, validation, cache directives, invalidation, and sensitive-information limits.

Reviewed 2026-09-27
IETFRFC 8246: HTTP Immutable Responses ↗

Defines immutable caching, its scope, and corruption considerations.

Reviewed 2026-09-27
MDN Web DocsHTTP caching ↗

Practical guidance on validators, 304s, personalization, and cache-busting.

Reviewed 2026-09-27
MDN Web DocsCache-Control header ↗

Reference for max-age, s-maxage, no-cache, no-store, private, public, and must-revalidate.

Reviewed 2026-09-27
MDN Web DocsETag header ↗

Explains entity tags, If-None-Match, and 304 validation.

Reviewed 2026-09-27
web.devPrevent unnecessary network requests with the HTTP Cache ↗

Practical guidance on versioned URLs, validators, policies, and deployment.

Reviewed 2026-09-27

Source policy. This article uses read standards and first-party technical documentation. It avoids unsupported performance claims and separates HTTP rules from platform-specific configuration.

QUICK CLARIFICATIONS

Common questions.

Does no-cache mean a browser cannot store the page?

No. no-cache allows storage but requires successful validation with the origin before reuse. Use no-store only when the response should not be stored, while recognizing that no-store alone is not a complete privacy safeguard.

Should every static file receive a one-year cache lifetime?

No. A one-year max-age is appropriate only when the URL's bytes will not change during that period, usually because the URL is fingerprinted or versioned. Mutable same-URL files need a shorter or validation-first policy.

Can a CDN purge fix a browser caching mistake?

It can remove a managed shared-cache copy, but it cannot force every browser to discard a fresh response. Publish a new versioned asset URL and update HTML references; then use the rollback plan to restore a compatible generation if needed.

Status Is UP Editorial Team · Uptime Enablement Editors

Reviewed by Web performance and release engineering reviewer. Published 2026-09-27; updated 2026-09-30.