[PATCH] Upstream: add $upstream_cache_age variable

Piotr Sikora piotr at cloudflare.com
Mon Oct 20 09:56:29 UTC 2014


Hey Roman,
sorry for late reply.

> Another issue i’ve found reading the RFC.
>
> If the reason for $upstream_cache_age is adding HTTP Age response header then it makes
> sense to improve age calculation algorithm.

It is and it isn't ;)

There are two use cases for this variable:

1. Exposing it as "Age" or "X-Cache-Age" HTTP response header. The RFC
describes "Age" as the time that passed since the response was
generated at the origin server, taking into account the information
from the intermediary proxies (in practice - just the previous one).
As you've already noticed, this variable shows time that passed since
the response was received (or revalidated) and ignores information
from the intermediary proxies, so using it for as the "Age" header
isn't strictly RFC-conformant, but it's "good enough" and it's
actually what most people we've been dealing with expect to see.

2. Logging of the cached file's age to the access logs. The more
information you have in the logs when you need them, the better...
That should go without saying ;)

Best regards,
Piotr Sikora



More information about the nginx-devel mailing list