🌍Cache-Control Header
Also known as Cache-Control, HTTP Caching, Cache Headers
An HTTP header. It tells browsers and CDNs how long they may keep a copy of a file.
Think of it like
It is like the best-before date on a milk carton. It tells you how long you can keep it.
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.
Why it matters
Good caching makes repeat visits fast and saves bandwidth. Bad caching shows people old pages.
Definition
Example code
http
Cache-Control: max-age=86400Common mistake
Key takeaways
- 1How long. max-age, in seconds.
- 2Who keeps it. Browsers and CDNs.
- 3Never keep. no-store, for private data.