DNS TTL & caching · Lesson 2 of 8 · 3 min read
The cache hierarchy
A single lookup can pass through many caches, each holding answers for up to the TTL (or its own rules):
Enlarge diagram
Swipe sideways to see all of it, or tap to open it full screen.
| Layer | Behaviour |
|---|---|
| Browser | Chrome/Firefox keep their own short-lived cache (Chrome ~1 minute regardless of TTL) |
| OS | systemd-resolved (Linux), the Windows DNS Client service and macOS mDNSResponder honour TTL; minimal Linux containers often have no OS cache |
| Node-level (Kubernetes) | CoreDNS cache plugin (default cache 30 — caps at 30 s); NodeLocal DNSCache on each node |
| Recursive resolvers | Shared by many users — a popular record is almost always cached somewhere; may cap TTLs |
| Application runtime | JVM, .NET and others may cache independently; connection pools keep using already-connected IPs |
Two features of modern resolvers to know:
- Prefetching — the resolver refreshes popular records shortly before their TTL expires, so users never pay for the cache miss.
- Serve-stale (RFC 8767) — if the authoritative servers are unreachable when a record expires, the resolver keeps serving the expired answer for a while rather than failing. This makes DNS provider outages less visible, but also means "expired" doesn't always mean "gone".
Flushing caches you control:
resolvectl flush-caches # systemd-resolved
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder # macOS
ipconfig /flushdns # Windows
kubectl -n kube-system rollout restart deploy/coredns # CoreDNS (cache is per pod)
You can't flush the world's ISP and public resolvers — Google and Cloudflare offer manual "flush cache" pages for their resolvers, but everyone else simply waits for the TTL.