Unit 9 · Ship it and keep it alive
Reading cache headers: HIT, age and cache-control
A cache HIT means the CDN had a stored copy and served it. age is how old that copy is, in seconds. cache-control says how long the copy may be kept.
The mix-up
What people often think
“HIT means the copy has expired.”
What the tutor says
HIT means the CDN had a copy and used it. cache-control says how long it may keep that copy.
How it works
age is not downtime: a site that is down does not answer 200 at all. A large age on a page that should have changed points at a stale cache.
An example
HTTP/2 200
cache-control: public, max-age=3600
x-cache: HIT
age: 2950Close cousins of this mix-up
The tutor watches for these in the same lesson.
“The age header counts how long the site has been down.”
A down site does not answer 200. age is how old the copy you got is, in seconds.
Practise it with a tutor watching
Caches
Tell stale from broken by reading cache headers, then clear the right cache instead of redeploying blindly.
Free, no account needed.