Cache TTL Calculator

Cache TTL Calculator

Setting cache headers for your content? This calculator recommends a TTL based on how often the content actually changes.

Recommended TTL = Content Update Frequency(days) x Safety Factor

Example

Content updates roughly weekly, 0.5 safety factor:

Recommended TTL = 7 x 0.5 = ~302,400 seconds (3.5 days)

Why a Safety Factor Below 1.0 Is Recommended

Setting cache TTL shorter than your actual content update frequency, using a safety factor below 1.0, reduces the risk of serving stale cached content to users well after an update has occurred - a TTL exactly matching update frequency leaves no margin for irregular update timing.

The Tradeoff to Keep in Mind

The tradeoff for a shorter, safer TTL is somewhat reduced cache hit rate and higher origin server load compared to a longer TTL - balancing content freshness against server load and CDN cost is the core tension this calculation helps navigate.