{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreihsxceuu3qiszdsu46tjjdcjnnmdkpbz73vvduvr3jomhckddnwfa",
    "uri": "at://did:plc:5sgu76a53rz3n6unbykmovqy/app.bsky.feed.post/3mlofc2aiy562"
  },
  "description": "TTL (Time To Live) is the duration for which a cached value, DNS record, or other transient piece of data remains valid. After the TTL expires, the entry is considered stale and either evicted, refreshed, or revalidated. TTL is one of the simplest knobs in cache design with outsized impact on hit rate and freshness.\n\n\nHow it appears in different systems\n\n * Caches: per-key TTL on Redis or Memcached entries; sets the lifetime independent of the eviction policy.\n * HTTP: Cache-Control: max-age=360",
  "path": "/engineering-glossary/ttl-time-to-live/",
  "publishedAt": "2026-05-12T18:12:44.000Z",
  "site": "https://sahilkapoor.com",
  "tags": [
    "Caching",
    "CDN",
    "Redis",
    "Eviction Policy",
    "JWT",
    "Synchronized Expiration in Distributed Systems"
  ],
  "textContent": "**TTL (Time To Live)** is the duration for which a cached value, DNS record, or other transient piece of data remains valid. After the TTL expires, the entry is considered stale and either evicted, refreshed, or revalidated. TTL is one of the simplest knobs in cache design with outsized impact on hit rate and freshness.\n\n## How it appears in different systems\n\n  * **Caches:** per-key TTL on Redis or Memcached entries; sets the lifetime independent of the eviction policy.\n  * **HTTP:** `Cache-Control: max-age=3600` tells browsers and CDNs how long to cache a response.\n  * **DNS:** each record has a TTL; resolvers and clients cache it for that long before re-querying the authoritative server.\n  * **Tokens:** the `exp` claim in a JWT is effectively a TTL on the token's validity.\n  * **Databases:** some stores support TTL indexes (MongoDB, DynamoDB) that auto-delete documents after a duration.\n\n\n\n## Choosing a TTL\n\n  * **Shorter TTL.** Fresher data, lower hit rate, more origin load.\n  * **Longer TTL.** Higher hit rate, lower origin load, staler data and slower invalidation if something changes.\n  * **Stale-while-revalidate.** Serve stale content immediately and refresh asynchronously, getting both speed and eventual freshness.\n\n\n\nšŸ”—\n\n**Related Terms**\nCaching, CDN, Redis, Eviction Policy, JWT\n\nšŸ“–\n\n**Further Reading**\nSynchronized Expiration in Distributed Systems",
  "title": "TTL",
  "updatedAt": "2026-05-13T19:10:59.843Z"
}