← Lessons

quiz vs the machine

Gold1350

Networking

DNS Caching and TTL

How resolvers cache records and how TTL controls when they refresh.

4 min read · core · beat Gold to climb

Why cache DNS

Every name lookup that walked the full hierarchy from root to authoritative server would be slow and would overload those servers. So resolvers cache answers and reuse them for repeat lookups.

The TTL

Each DNS record carries a time to live, the TTL, set by the zone owner:

  • While the TTL has not expired, the resolver answers from cache without asking again.
  • When the TTL expires, the entry is evicted and the next lookup fetches a fresh record.
  • A short TTL means faster propagation of changes but more queries and load.

This is the central tradeoff. A low TTL lets you move a service quickly during a migration or failover, while a high TTL cuts query volume and latency but makes changes slow to take effect.

Operational care

Before a planned change, operators often lower the TTL in advance so the old value drains from caches, then make the change, then raise it again. Forgetting this leaves stale answers lingering for the full old TTL.

Key idea

DNS resolvers cache records until their TTL expires, trading propagation speed against query load whenever the TTL is set.

Check yourself

Answer to earn rating on the learn ladder.

1. What does a DNS record TTL control?

2. Why lower a TTL before a planned DNS change?