Skip to content

Cache TTL Calculator

Convert a cache duration into seconds and ready-to-use headers.

Total TTL

3,600 seconds

1 hour

HTTP Cache-Control

Cache-Control: public, max-age=3600

Redis (SET with TTL)

SET key value EX 3600

Redis (EXPIRE)

EXPIRE key 3600

Next.js revalidate

export const revalidate = 3600;

Milliseconds

3600000

Enter a duration in days, hours, minutes, and seconds to get the total TTL in seconds and milliseconds, plus copy-ready snippets for the places you actually set it: an HTTP `Cache-Control: max-age` header, a Redis `SET ... EX` or `EXPIRE` command, and a Next.js `revalidate` export.

Most caching systems expect a TTL in seconds, and it is easy to fat-finger a conversion — 24 hours is 86,400 seconds, not 8,640. This tool does the arithmetic for you so your CDN, Redis key, and framework cache all agree. Everything runs in your browser.

Frequently asked questions

Is a cache TTL set in seconds or milliseconds?

It depends on the system. HTTP `Cache-Control: max-age` and Redis `EXPIRE` use seconds, while many JavaScript APIs use milliseconds. This tool shows both so you copy the right unit — a common bug is passing a seconds value where milliseconds are expected, making a cache expire 1000× too soon.

What is a good TTL for my cache?

It is a trade-off: a longer TTL means fewer origin hits but staler data. Rarely changing assets (images, versioned JS) can use days or a year with immutable; frequently changing API data often uses seconds to minutes. Pair a short TTL with explicit invalidation when the underlying data changes.