[PATCH] Upstream: fix the cache duration calculation

Florent Le Coz florent.lecoz at smartjog.com
Thu Nov 14 17:44:00 UTC 2013

On 11/14/2013 06:14 PM, Maxim Dounin wrote:
> Hello!
Thanks for your quick review.

I’ll provide a (actually two) revised patch later, meanwhile here are a 
few comments and questions.

> As used in the patch, it looks like there is no need for a special
> process function for the Age header.

Indeed, but this is used in my subsequent patch. I will remove that from 
the first patches.

> Processing Cache-Control header in
> ngx_http_upstream_send_response() is at least sub-optimal, and may
> cause unneeded work if caching is disabled with, e.g.,
> "Cache-Control: no-cache".
> At most, this should be done in ngx_http_upstream_process_headers(),
> but even this will be too late for upcoming cache revalidation
> with conditional requests.
> [...]

Where would you then process these values, if not after every headers 
have been processed? At the moment, nginx processes them one by one, in 
the order there are found in upstream’s response. Do you suggest that in 
process_cache_control I add some "if 'expires' has already been 
processed" condition, and something equivalent in 
'process_cache_control'? That doesn’t look ideal to me, hence why I 
chose to set the valid_sec value once every header has been processed.

Do you have any suggestion?

Thank you

Florent Le Coz

More information about the nginx-devel mailing list