1001Ferramentas
Dev

Cache-Control max-age Explained

Convert the Cache-Control max-age value (in seconds) into a readable time in hours and days. Useful for understanding and debugging HTTP cache and CDNs.

Duração

How long 31536000 seconds actually is

You open DevTools, see Cache-Control: max-age=604800 and stall trying to divide it in your head. Or you copied the number from a tutorial and have no idea whether you are caching for five minutes or five days, which matters a lot the day a bad deploy goes out. Paste the seconds and the page gives you the equivalent in minutes, hours, days or years, switching units as the value grows.

max-age does not start counting when the file reaches your browser. It counts from the moment the response was generated, and the Age header tells you how much of that budget was already burned inside a proxy or CDN. A max-age=3600 response arriving with Age: 3500 is good for another hundred seconds. To treat browsers and CDNs differently there is s-maxage, which overrides max-age in shared caches. The conversion here assumes a 365-day year.

The field takes any number, but in the spec max-age is a non-negative integer. Fractional or negative values are treated by caches as invalid or already stale. A full year, 31536000, only makes sense for files with a versioned name such as app.4f2c1.js, otherwise users get stuck on an old build with no way out. For HTML the usual answer is no-cache plus an ETag. This page only translates the number, it does not build the header.

Frequently asked questions

How long is 31536000 seconds?
One 365-day year, the value people typically cap at for versioned assets. Some older guides quote 31556926, which is the astronomical year.
Are max-age=0 and no-store the same thing?
No. With max-age=0 the cache still stores the response and revalidates on every use, which can still produce a 304. With no-store nothing is written to disk or memory.
Does the tool generate the Cache-Control header for me?
No. It converts a value in seconds into readable time. Assembling the full directive, with public, immutable or s-maxage, is still manual work.

Related Tools