0

In Section 14.9.3. of the "HTTP 1/1. Specification", the behaviour the Cache-Control: max-age header field is described. In particular, it states:

"When the max-age cache-control directive is present in a cached response, the response is stale if its current age is greater than the age value given (in seconds) at the time of a new request for that resource"

How is the "current age" (as used in the specification) of the response measured? Is it measured as the difference between the current time and:

  1. the value of the Date: header of the response
  2. the value of the Last-Modified: header of the response
  3. the time the response was put into the cache (which may differ from a and b)

?

jonseymour
  • 1,006
  • 1
  • 12
  • 22

2 Answers2

1

Please see http://greenbytes.de/tech/webdav/draft-ietf-httpbis-p6-cache-24.html#header.age and check whether the revision makes it clearer.

Julian Reschke
  • 40,156
  • 8
  • 95
  • 98
  • Thanks - I see section 4.2.3 of that reference (or 13.2.3 of my reference) does define what current age means. It might help, I think, if Section "5.2.2.8 max-age" made reference to Section 4.2.3. – jonseymour Sep 27 '13 at 06:51
0

"Cache-control: max-age can be useful also when we output HTML. Imagine pages generated by PHP that changed not so often, once per day or even longer. But browsers still have to download HTML every page view. We can improve it by sending max-age value in PHP. header('Cache-Control: max-age=28800');

This way we set desirable cache lifetime to 8 hours. Now if someone is clicking a link for second time within 8 hours period he gets the page instantly.

Max-age also helps to make proxy servers more efficient. We can easily organize transparent server-side caching by adding proxy server to web frontend.

Note that there is not easy case if pages have content that changes often and that’s relevant. For example, there can be difficulties in caching pages with login form that transforms into some box with «Hello username» after user login or if there are user comments, the user who posted commentary will not see it. Because we cannot ask browser to destroy cache entry, it will still get the old page from cache. The solution can be using Javascript to generate login box (requires enabled Javascript). If we set a cookie after user logged in, we can check it on client-side and generate suitable content for the logged in user. This way the content will be the same from server side view and can be cached."

Details can be found here[http://www.webscalingblog.com/performance/caching-http-headers-cache-control-max-age.html]

Jabir
  • 2,776
  • 1
  • 22
  • 31
  • Thanks. My question was specifically regarding the interpretation of the term "current age" in the HTTP 1.1 specification and your answer does not really address that question. In other words, is it 1, 2, 3 or something else? – jonseymour Sep 27 '13 at 06:00