Deutsch
Servers, HTTP & caching

Cache-Control

Also known as: Cache-Control header

Cache-Control is an HTTP header that tells browsers and shared caches such as CDNs whether and for how long they may store a response. It can appear in responses and in requests. Directives are separated by commas and are case-insensitive.

Which directives are important?

Directive Meaning
max-age=N The response stays fresh for N seconds after it was generated.
s-maxage=N Same as max-age, but only for shared caches such as CDNs.
no-cache The response may be stored, but must be revalidated with the server before each reuse.
no-store The response must not be stored in any cache.
private Only a private cache, such as the browser, may store it.
public Shared caches may store it, even for requests with authorization.
must-revalidate After it becomes stale, the response must be revalidated before reuse.
immutable The response will not change while fresh, so no revalidation is needed.
stale-while-revalidate=N A stale response may be served for N seconds while a fresh copy is fetched in the background.

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

The names are easy to mix up. no-cache allows storing and requires a check with the server before reuse, which often results in a 304 Not Modified. no-store forbids storing. According to RFC 9111, no-store is not a reliable mechanism for privacy, since it relies on caches behaving as specified.

Common patterns

  • Versioned static files: Cache-Control: max-age=31536000, immutable
  • HTML pages that should always be checked: Cache-Control: no-cache
  • Personalized content: Cache-Control: private
  • Content for a CDN: Cache-Control: public, s-maxage=3600

Example

HTTP
HTTP/1.1 200 OK
Cache-Control: public, max-age=604800
ETag: "33a64df5"

Cache-Control and crawlers

Google’s crawlers support ETag and Last-Modified for conditional requests. Setting a validator together with Cache-Control lets repeated requests end in 304 Not Modified. Google writes that max-age is not required, but worth considering as an addition so crawlers can tell when to recrawl a URL. Other HTTP caching directives are not supported by Google.

Cache headers and 304 compared
Header / statusRequest counterpartWhat it doesRelevance for Google's crawlers
Cache-Control (this term)– (directives can also appear in requests)lists directives for caches, e.g. max-age (fresh for N seconds), no-cache (reuse only after revalidation), no-store (do not store)max-age is optional and helps crawlers decide when to recrawl the URL; Google does not support other caching directives
ETagIf-None-Matchidentifier for the current version of a resourcesupported and recommended by Google because it has no date formatting issues; takes precedence when both validators are present
Last-ModifiedIf-Modified-Sincedate and time at which the server believes the resource was last modifiedsupported; the date must follow the HTTP format, e.g. Fri, 4 Sep 1998 19:15:56 GMT
304 Not Modifiedresponse to a conditional GET or HEAD requestsignals that the stored copy is still valid; the response has no bodythe crawler tells the next system that the content is the same as at the last crawl; Search may recalculate signals, otherwise no effect on indexing

Google suggests setting both ETag and Last-Modified, since other applications use them too. Whether a Google crawler uses caching depends on its product: Googlebot uses it when recrawling URLs for Google Search. According to Google's December 2024 blog post, only 0.017% of all fetches could be served from cache. Sources: Google Crawling Infrastructure: Overview of Google crawlers and fetchers, HTTP caching (last updated 2026-06-12); Google Search Central Blog: Crawling December: HTTP caching (2024-12-09); Google Crawling Infrastructure: HTTP status codes, network and DNS errors (last updated 2026-02-04); MDN: HTTP caching; RFC 9111: HTTP Caching; RFC 9110: HTTP Semantics (8.8.2 Last-Modified, 8.8.3 ETag, 15.4.5 304). Last checked: .

Sources

  1. Cache-Control – MDN Web Docsdeveloper.mozilla.org
  2. HTTP Caching, RFC 9111rfc-editor.org
  3. HTTP caching – MDN Web Docsdeveloper.mozilla.org
  4. Overview of Google crawlers and fetchers (HTTP caching) – Google Search Centraldevelopers.google.com

Last updated: