Cache-Control Header Explained

What the HTTP Cache-Control header does and when it's used.

Published October 14, 2026

Cache-Control tells browsers and caches how, and for how long, a response may be stored. Directives include max-age, no-store, no-cache, public, private and immutable.

How it works

It is the primary tool for performance and freshness. It overrides older Expires headers.

The Cache-Control header is part of the HTTP message and is case-insensitive in name.

In a real exchange

curl -i https://example.com/
Cache-Control: public, max-age=31536000, immutable
Where Cache-Control appears.

Practical examples

The header

Cache-Control: public, max-age=31536000, immutable

Set or use it in code

add_header Cache-Control "public, max-age=31536000, immutable";

Inspect it

curl -sI https://example.com | grep -i 'cache-control'

Common mistakes

  • Using no-cache when you mean no-store
  • Long max-age on HTML
  • Caching private data with public

Key takeaways

  • Cache-Control: Cache-Control tells browsers and caches how, and for how long, a response may be stored.
  • Check it in browser DevTools → Network.
  • Test with curl -I before deploying.

FAQ

no-cache vs no-store?

no-cache allows storing but requires revalidation; no-store forbids storing.

Is Cache-Control case sensitive?

Header names are case-insensitive; values may not be.

More HTTP articles