Skip to main content

4.9.1. Freshness

4.9.1. Freshness

The freshness of a cached response determines whether it can be used to satisfy a request without contacting the origin server. Freshness is controlled by the Cache-Control header field and related mechanisms.

Applications SHOULD specify freshness information for cacheable responses. This can be done using:

  • Cache-Control: max-age=N to indicate that the response can be cached for N seconds.

  • Cache-Control: s-maxage=N to provide a different freshness lifetime for shared caches.

  • Expires header field to specify an absolute expiration time (though Cache-Control is preferred).

For example:

Cache-Control: max-age=3600

indicates that the response can be cached for up to one hour.

Applications SHOULD choose freshness lifetimes carefully, balancing:

  • The need for performance (longer lifetimes reduce requests).

  • The need for freshness (shorter lifetimes ensure clients see updates sooner).

  • The characteristics of the resource (how often it changes).