Skip to main content

Cache TTL Calculator

Convert a cache TTL between seconds, minutes, hours, days and weeks, and generate the matching Cache-Control: max-age header with a human-readable duration breakdown.

Input

The cache duration to convert.

Output

Result
MetricValue
No data yet
Was this helpful?

Guides

A cache TTL (time-to-live) is how long a stored response — a browser cache entry, a CDN edge cache, a Redis key — is considered "fresh" before it must be re-fetched or re-validated against the origin. On the web, the most common way to express a TTL is the HTTP Cache-Control: max-age=<seconds> response header, where the value is always in seconds, not minutes or hours. That mismatch — thinking in hours or days but having to type seconds — is where mistakes creep in (a typo turns "1 day" into 864 seconds instead of 86400).

This calculator removes the arithmetic. Enter a TTL value and pick its unit (seconds, minutes, hours, days or weeks), and it instantly converts the value to total seconds, spells out a human-readable duration, and writes the matching Cache-Control: max-age= header string you can paste straight into server config, a CDN rule, or application code.

How to use it

  1. Enter the TTL Value — any non-negative number, including decimals (e.g. 1.5).
  2. Choose the Unit — Seconds, Minutes, Hours, Days or Weeks.
  3. Read the result table:
    • Total Seconds — the raw number max-age expects.
    • Human-Readable Duration — the same value broken into weeks, days, hours, minutes and seconds (e.g. "1 day, 12 hours").
    • Cache-Control Header — the ready-to-use header string (Cache-Control: max-age=7200).
    • Expires Header (relative) — a reminder that the older Expires header (an absolute date) is equivalent to "the current time plus this many seconds," for systems that still emit Expires instead of max-age.

The result updates automatically as you type — there's no button to click.

FAQ

Why seconds specifically? max-age (and its shared-cache sibling s-maxage) are defined in the HTTP spec as an integer number of seconds. This tool rounds fractional results (e.g. 1.5 minutes) to the nearest whole second, since max-age doesn't support fractions.

What does max-age=0 mean? Zero seconds means the cached response is immediately stale — clients should revalidate with the origin before reusing it. It's different from no-store, which forbids storing the response at all; max-age=0 still allows caching, just with mandatory revalidation.

Is there a maximum useful TTL? Practically, values much beyond a year (31536000 seconds) rarely add value — most browsers and CDNs cap effective caching well below that, and very long TTLs make it hard to roll out changes without cache-busting (e.g. versioned filenames). Days-to-weeks is typical for static assets; seconds-to-minutes is typical for dynamic API responses.

What about s-maxage, stale-while-revalidate, or other Cache-Control directives? This tool focuses on converting a single TTL into max-age. Any of the directives above use the same "seconds" unit, so the Total Seconds value here plugs directly into s-maxage=<seconds>, stale-while-revalidate=<seconds>, etc. if you're hand-assembling a more complex header.

Privacy

Everything runs locally in your browser — the TTL value you enter is never sent to a server.

cachettlcache-controlhttp-headermax-agecalculator

Use it from code

From 3 credits per call

REST API

curl -X POST https://api.iotools.cloud/v1/tool/cache-ttl-calculator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "2",
    "unit": "hours"
  }'

Swap in your own key from your account. The tool's fields are the body — no wrapper.

Ask an AI agent

Use the IOTools `cache-ttl-calculator` tool (Cache TTL Calculator) on this input:

YOUR_INPUT_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.