I came cross a case where the Cache-Control: public, max-age=31622400, immutable which make 366 days, however it seems the best practice to be not greater than 31536000 which makes it 365 days, my question is, is the max-age considered invalid date if the number of seconds is 366days or more? also will be helpful if you can refer links or docs

1

There are 1 best solutions below

0
On

There is no particular limit on the value of max-age. You can see that in the RFC definition of max-age (and delta-seconds).

The reason people sometimes use a one-year limit is that an old version of the specification limited the expiration time given by the Expires header:

To mark a response as "never expires," an origin server sends an Expires date approximately one year from the time the response is sent. HTTP/1.1 servers SHOULD NOT send Expires dates more than one year in the future.

This is what the current specification says on that subject:

Historically, HTTP required the Expires field value to be no more than a year in the future. While longer freshness lifetimes are no longer prohibited, extremely large values have been demonstrated to cause problems (e.g., clock overflows due to use of 32-bit integers for time values), and many caches will evict a response far sooner than that.