Free auditStart free
GlossaryGlossary · Performance

HTTP caching

HTTP caching lets browsers, proxies, and CDNs store and reuse responses. Learn freshness, validation with ETag, and which headers to set.

5 min
read
5
sources
Oct 21, 2026
updated
Scaplet Editorial Team
author
In one line

HTTP caching is the standard way browsers, proxies, and CDNs store a response and reuse it for later requests instead of fetching it again. A stored response is either fresh, so it is reused as is, or stale, so the cache must validate it with the origin first. Headers such as Cache-Control, ETag, and Last-Modified control both steps.

30-second check

Is this costing your site traffic?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
01Worth knowing

How HTTP caching works

When a client asks for a URL, a cache between it and the origin server can answer from a stored copy. The standard that defines this is RFC 9111, which "defines HTTP caches and the associated header fields that control cache behavior or indicate cacheable response messages." The saved copy is in one of two states, based on age. Age is the time since the response was generated.

Fresh

the age is below the lifetime you set, so the cache serves it without contacting the origin.

Stale

the lifetime has passed. The cache does not throw the copy away. It asks the origin whether the copy is still good, which is called validation.

Validated

if the origin answers 304 Not Modified, the stored copy becomes fresh again and no body is sent.

Per MDN, a validation request is conditional: it carries If-None-Match (from the ETag) or If-Modified-Since (from Last-Modified). If both are present, If-None-Match takes precedence.

03At a glance

The headers that matter

Header

Cache-Control: max-age=N

Job
Sets freshness in seconds
Notes from the docs
MDN: max-age wins over Expires when both are present
Header

ETag

Job
Validator: a server-chosen value for this version
Notes from the docs
Any value works, such as a content hash
Header

Last-Modified

Job
Validator: a timestamp
Notes from the docs
MDN says to send both ETag and Last-Modified when possible
Header

Vary

Job
Lists request headers that change the response
Notes from the docs
Vary: Accept-Language caches each language separately
Header

no-cache

Job
Forces validation before every reuse
Notes from the docs
It does not stop the response from being stored
Header

no-store

Job
Do not store the response
Notes from the docs
MDN warns it also gives up the browser back/forward cache

Details of each directive are on the Cache-Control page.

04Worth knowing

Tips most guides miss

Heuristic caching is real

MDN says that without Cache-Control, a response with a Last-Modified date can still be stored and reused, and the spec suggests about 10% of the time since the last change. MDN's advice is to give all responses an explicit Cache-Control header.

Don't use `User-Agent` in `Vary`

MDN notes it has so many variations that it drastically reduces cache reuse.

Cookies are not a privacy switch

MDN says a cookie alone does not make a response private. Use Cache-Control: private for personalized content.

You can't recall a long-lived response

MDN states there is no way to delete responses stored on intermediate servers with a long max-age. Change the URL (a version or hash in the filename) when the file changes, as web.dev advises.

`immutable` is for fingerprinted files

MDN's example is Cache-Control: max-age=31536000, immutable, which skips revalidation on reload for content that never changes.

05Explained

What Googlebot supports

Google's crawler documentation says its crawling infrastructure "supports heuristic HTTP caching as defined by the HTTP caching standard," specifically ETag with If-None-Match, and Last-Modified with If-Modified-Since. If both validators are present, Google's crawlers use the ETag value. Google adds "Other HTTP caching directives aren't supported."

It also says to consider setting max-age to help crawlers decide when to recrawl, set to the number of seconds the content is expected to stay unchanged. And individual Google crawlers may or may not use caching: Googlebot supports caching when re-crawling URLs for Search. Google also recommends setting both ETag and Last-Modified, since other applications such as CMSes use them too.

06Check it

Check it in two minutes

Run it twice. A shared cache that served the copy usually adds an Age header. The Network panel in your browser DevTools shows the status of each request, and a validated response comes back as 304. Repeat for an HTML page and a hashed asset: the page should revalidate or have a short lifetime, the asset a long one.

Look at the headers of any URL
curl -sI https://example.com/styles.css | grep -i -E 'cache-control|etag|last-modified|vary|age'
Questions

Asked a lot.

5 questions people ask next, answered from the sources on this page.

01What is the HTTP cache?

It is the set of browser and intermediary caches that store HTTP responses and reuse them for later requests. web.dev calls the browser's HTTP Cache your first line of defense against unnecessary network requests, and notes it is a collection of web platform APIs rather than a single API.

02What is the difference between no-cache and no-store?

Per MDN, no-cache lets a response be stored but requires validation with the origin before each reuse. no-store tells caches not to store the response at all.

03How do I cache a website?

Set an explicit Cache-Control header on every response. Give fingerprinted static files a long max-age, and give HTML a short lifetime or no-cache with an ETag so it revalidates. Send private on personalized pages.

04Does Google use HTTP caching when it crawls?

Yes, for some crawlers. Google documents support for ETag with If-None-Match and Last-Modified with If-Modified-Since, and says Googlebot supports caching when re-crawling URLs for Search.

05How long should I cache a page?

It depends on how often the content changes. The docs fix the mechanics: max-age is seconds of freshness, and a response stored with a long max-age can't be deleted from intermediate caches, so change the URL when the file changes. Web.dev suggests max-age=31536000 for versioned resources and no-cache for resources that should be revalidated before every use.

Sources · 5

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • mozilla.org
  • rfc-editor.org
  • web.dev
  • google.com
  1. 01HTTP caching - MDN Web Docsdeveloper.mozilla.org · checked 2026-10-25
  2. 02RFC 9111: HTTP Cachingrfc-editor.org · checked 2026-10-25
  3. 03Prevent unnecessary network requests with the HTTP Cache - web.devweb.dev · checked 2026-10-25
  4. 04RFC 9213: Targeted HTTP Cache Controlrfc-editor.org · checked 2026-10-25
  5. 05Google crawlers and fetchers overview (HTTP caching)developers.google.com · checked 2026-10-25
Free · 2 minutes

Know the term. Now check your site.

The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • +212% organic clicks in 90 days Ledgerly