An expiration date, or time-to-live (TTL), limits how long a cached entry remains valid. After that period, the entry is considered stale and must be removed, refreshed, or retrieved again from the backing store. section 6.7 section 6.11
TTL provides a simple freshness boundary, but its setting creates practical trade-offs:
- Choose the duration in units such as seconds, minutes, hours, or days according to the data’s update rate and freshness requirements. section 6.7
- Use a shorter TTL to expose backing-store changes sooner, accepting more retrievals and potentially a lower cache hit ratio. section 6.11 section 6.7
- Use a longer TTL to retain more cache hits, accepting a greater chance that applications read stale data. section 6.11
- Track each entry’s insertion time and TTL, then compare the expiration time with the current time during lookup or periodic checks. section 6.7
DNS records
DNS caches domain-name-to-IP-address mappings. A stable mapping may use a TTL of 24 hours or more, while a dynamic record used for load balancing may use about 30 seconds so configuration changes become visible quickly. section 6.7
TTL addresses freshness rather than capacity. Replacement policies such as LRU, LFU, and FIFO evict entries when space is needed; TTL can expire an entry even when the cache has room. section 6.7 section 6.11



