DNS & Naming

DNS caching

If every visit to a website triggered the full root-to-authoritative walk, DNS would be slow and the root servers would be crushed. Caching is the fix: once a resolver learns an answer, it keeps a copy for a while and reuses it. It is like jotting a friend's number in your own contacts after looking it up once — next time you just read it off your list instead of phoning directory assistance again. Caching is what lets DNS handle billions of lookups a second without melting.

Concretely, when a recursive resolver finishes resolving a name, it stores the resulting records in memory, tagged with how long they may be kept (the TTL that came with each record). For the duration of that TTL, any later query for the same name is answered straight from the cache — no walk, no contacting the authoritative server. Caching happens at several layers: in the recursive resolver (which serves many users and gets the most hits), in your operating system, and even inside your browser. A popular name like a major site is almost always already cached close to you.

Why it matters: caching is the single biggest reason DNS scales, and it explains the everyday speed difference between the first lookup of a site (a little slow) and every lookup after (instant). The honest trade-off is freshness: a cached answer can be stale. If you change where a name points, resolvers and clients keep serving the old address until their cached copies expire — that delay is the famous slow propagation of DNS changes. Lowering a record's TTL ahead of a planned change shrinks that window, at the cost of more frequent lookups.

First person on an office network visits example.com: their resolver does the full walk and caches the A record with a 300-second TTL. For the next 5 minutes, everyone else in the office who visits example.com gets the answer instantly from that cache.

First lookup pays the full cost; the rest ride the cache for free.

Caching is also why DNS changes do not take effect instantly. Old answers linger in caches until their TTL runs out, so a name can still resolve to its previous address for a while after you update it.

Also called
DNS cachecaching resolutionDNS 快取名稱快取