The maximum value for the cache control header in HTTP

I use Amazon S3 to serve static resources for my site. I want browsers to cache these assets for as long as possible. Which metadata headers should be included with my assets.

Cache-Control: max-age=??? 
+45
caching cache-control
Aug 15 2018-11-11T00:
source share
3 answers

Usually one year is recommended as the standard maximum value. See RFC 2616 :

To mark the response as “never expires”, the origin server sends the expiration date approximately one year from the time the response is sent. HTTP / 1.1 servers MUST NOT send expiration dates of more than one year in the future.

Although this applies to the older expires standard, it makes sense to refer to cache-control also in the absence of any explicit guidance on the standards. This is as long as you need it at all, and choosing any arbitrarily longer value may cause some user agents to crash. So:

 Cache-Control: max-age=31536000 
+61
Aug 08 '14 at
source

Consider not storing it "as long as possible", but instead settle it as long as it is wise. For example, it is unlikely that you will need to cache it longer than say 10 years ... am I right?

The RFC discusses max-age here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.3

Eric Lawrence says that before IE9 Internet Explorer would treat any resource as obsolete with Cache-Control: the maximum age is over 2147483648 (2 ^ 31) seconds, about 68 years ( http://blogs.msdn.com/b/ie /archive/2010/07/14/caching-improvements-in-internet-explorer-9.aspx ).

Other user agents will, of course, change, so ... try choosing a number that is unlikely (but not likely!) To cause an overflow. A maximum age of over 31536000 (one year) makes little sense, and unofficially this is considered a reasonable maximum value.

+16
Aug 15 '11 at 23:13
source

People who made a recommendation on maximum caching for 1 year did not think about it correctly.

First of all, if a visitor is served an outdated cached file, then why should he give any benefit so that he suddenly downloads a new version after 1 year? If the file has 1 year TTL, from a functional point of view, this means that the file is not intended to be modified at all.

So, why do you need more than 1 year?

1) Why not? You don’t need to tell your browser visitors “hey, this file is 1 year old, maybe it’s worth checking to see if it has been updated.”

2) CDN services. . Most content delivery networks use a cache header to decide how long to efficiently serve a file from an edge server. If you have 1 year of managing the cache for files, it will at some point begin to re-request immutable files from the source server, and the cache cache should be completely full, which will lead to slower loads for the client and unnecessary causes the origin.

What is the point of having a maximum of 1 year? Which browsers will throttle in an amount exceeding 31536000?

0
Mar 05 '15 at 7:31
source



All Articles