sajad torkamani

In a nutshell

A cached response is fresh if it’s still valid and can be reused. For example, its Expires value might be in the future or its ETag value might match what’s in the cache.

A response is stale if the cached response is no longer valid. For example, its Expires value might be a date in the past or its ETag value might not match what is in the cache.

How do you know if a response is fresh or stale?

You look at a response’s age – the time elapsed since the response was first generated.

Consider the following example HTTP response:

HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 1024
Date: Tue, 22 Feb 2022 22:22:22 GMT
Cache-Control: max-age=604800

<!doctype html>
…

For this response, its age is the time elapsed since Tue, 22 Feb 2022 22:22:22 GMT. This means that:

  • If the age of the response is less than one week, the response is fresh.
  • If the age of the response is more than one week, the response is stale.