Note · DNS
The cache that outlived its TTL
We changed an A record on a Tuesday morning. The TTL was sixty seconds. By lunch, one service was still talking to the old address, and the person who owned it had already spent an hour proving that “DNS is broken.” DNS was not broken. It was doing what several independent caches had been told to do.
The first useful move was to stop treating “DNS” as one thing. A lookup can pass through an authoritative server, a recursive resolver, the operating system’s stub resolver, the browser’s own cache, and a connection pool that has no idea a name was involved at all.
I started at the bottom and worked upward. A query straight to the authoritative server showed the new address and a clean TTL. A query to the recursive resolver showed the old address with a TTL that was still counting down, which meant the resolver had cached the answer before the change and had not yet expired it. That part was expected. The surprise was the client: even after its resolver returned the new address, it kept using the old one.
The client was not re-resolving because it did not need to. It had an open, healthy TCP connection to the old address, and the connection pool preferred reuse over a fresh lookup. From the application’s point of view, the name had never changed. This is the part that a TTL does not cover: a TTL says how long an answer may be cached, not how long a connection may live.
A TTL is a permission to forget, not an instruction to reconnect.
There are a few habits that make this less painful. If a cutover matters, lower the TTL well before the change, not at the same time. Query the authoritative server and the resolver separately so you know which layer is stale. Use a fresh hostname for the new endpoint when you can; a new name has no old connections and no old cache entries. And when a client insists on the old address, check its connection pool before you check its resolver.
The record was correct the whole time. The system around it had simply built three different kinds of memory, and only one of them was measured in seconds.