Skip to main content

5. Cache Leaks

Every resource record returned by a server is cached for TTL seconds, where the TTL value is returned with the RR. Full-service (or stub) resolvers cache the RR and answer any queries based on this cached information, in the future, until the TTL expires. After that, one more query to the wide-area network gets the RR in cache again.

Full-service resolvers might not implement this caching mechanism well. They might impose a limit on the cache size or might not interpret the TTL value correctly. In either case, queries repeated within a TTL period of a RR constitute a cache leak.

A Good/Bad Implementation​

BIND has no restriction on the cache size and the size is governed by the limits on the virtual address space of the machine it is running on. BIND caches RRs for the duration of the TTL returned with each record.

It does, however, not follow the RFCs with respect to interpretation of a 0 TTL value. If a record has a TTL value of 0 seconds, BIND uses the minimum TTL value, for that zone, from the SOA record and caches it for that duration. This, though it saves some traffic on the wide-area network, is not correct behavior.

Fixes​

  • a. Look over your caching mechanism to ensure TTLs are interpreted correctly.

  • b. Do not restrict cache sizes (come on, memory is cheap!). Expired entries are reclaimed periodically, anyway. Of course, the cache size is bound to have some physical limit. But, when possible, this limit should be large (run your name server on a machine with a large amount of physical memory).

  • c. Possibly, a mechanism is needed to flush the cache, when it is known or even suspected that the information has changed.