# Cache-Control Header

> An HTTP header. It tells browsers and CDNs how long they may keep a copy of a file.

**Field:** Infrastructure  
**Category:** Web Serving & Nginx  
**Also known as:** Cache-Control, HTTP Caching, Cache Headers

## Think of it like

It is like the best-before date on a milk carton. It tells you how long you can keep it.

## Definition

Cache-Control is an HTTP header that tells browsers, CDNs and proxies how long they may keep and reuse a copy of a file. The max-age part gives the time in seconds. While the copy is fresh, it is used without asking the server again. The no-store part means never keep a copy at all. Web servers can set it for each kind of file.

## Example

Jack's logo rarely changes, so his server sends max-age=86400 with it. Browsers keep it for a day before they ask again.

## Example code

```http
Cache-Control: max-age=86400
```

86,400 seconds is one day. Until then, the browser uses its own copy.

## Why it matters

Good caching makes repeat visits fast and saves bandwidth. Bad caching shows people old pages.

## Common mistake

Giving a long max-age to a file and then editing it under the same name. Visitors keep the old one until the time runs out.

## Three principles

- **How long.** max-age, in seconds.
- **Who keeps it.** Browsers and CDNs.
- **Never keep.** no-store, for private data.

## Related terms

- [HTTP Header](https://learn.benibix.com/term/infrastructure/http-header)
- [Content Delivery Network (CDN)](https://learn.benibix.com/term/infrastructure/content-delivery-network)
- [HTTP Response](https://learn.benibix.com/term/infrastructure/http-response)
- [Cache](https://learn.benibix.com/term/development/cache)
- [Cache Invalidation](https://learn.benibix.com/term/development/cache-invalidation)

![Visitors on the left reach a nearby CDN server that keeps copies of files for as long as their Cache-Control header allows. Requests it cannot answer go on to the origin, where a reverse proxy takes them over HTTPS and passes them to two app servers behind it.](https://learn.benibix.com/diagrams/inf2-reverse-proxy.svg)

---

Source: https://learn.benibix.com/term/infrastructure/cache-control
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
