Opscraft
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 diagramApplicationJVM DNS cache, connection poolsBrowserits own short cacheOperating systemsystemd-resolved, nscdNode or clusterNodeLocal DNSCache, CoreDNS cacheRecursive resolverISP, 8.8.8.8, 1.1.1.1, VPC ResolverAuthoritative serverthe source of truth (Route 53)you can flushthese yourselfyou cannot flushthe world's resolvers
Figure 1. One lookup can pass through many caches, each of which may hold the answer for up to its TTL. That is why "flush DNS" rarely fixes things for everyone.
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.