[PATCH 1 of 3] Correctly calculate and set Age header

Hiroaki Nakamura hnakamur at gmail.com
Thu Jul 18 12:51:53 UTC 2024


Hello,

2024年7月18日(木) 9:26 Maxim Dounin <mdounin at mdounin.ru>:
>
> Hello!
>
> On Mon, Jul 01, 2024 at 10:45:59PM +0900, Hiroaki Nakamura wrote:
>
> > Hello
> >
> > 2024年6月27日(木) 9:32 Maxim Dounin <mdounin at mdounin.ru>:
[...]
>
> Thanks for yet another version of the patch.  In its current form
> it starts to look reasonable.
>
> I've spent some time looking into this, including looking through
> previous attempts to implement some forms of Age support, notably:
[...]

Thank you for taking your time to investigate and implement Age support!

>
> Overall, there seems to be two major parts of what is expected to
> be done here:
>
> 1. Adjusting cache validity times based on the Age header in the
> upstream server response.
>
> 2. Returning cached responses with updated/added Age header.
>
> These two parts probably can be implemented separately, with
> minimal interdependencies.

I agree.

>
> Further, I tend to think that, while (1) probably can be the
> default, it might not be a good idea to do (2) by default, as in
> most setups [free]nginx is used as an origin server, even if
> caching is enabled.  In such configurations administrators often
> use "Cache-Control: max-age=N" for client-side caching, and
> control caching in [free]nginx separately, such as with
> proxy_cache_valid.  Adding the Age header in such configurations
> might result in unexpectedly non-working client-side caching.
>
> In particular, (2) can be implemented as a variable with relevant
> information to be used in the "add_header" directive if one needs
> to implement Age updating.  Alternative approach would be to add
> per-module directives to control (2), such as "proxy_cache_age on|off",
> and add the Age header in the upstream module, though a variable
> looks easier.

I agree the latter approach is better.

>
> Below are two patches that implement (1) adjusting cache validity
> base on the Age header and (2) a variable to set the Age header,
> and yet another patch to implement tests.  Please take a look.
[...]

I have looked at the two patches and the test.
Yes, it achieves what you described and it is a lot simpler and clearer
than my patches.
I also have verified that it covers both cases of orders of
cache-control and age headers, that is cache-control before age and
cache-control after age.

I have run the test with freenginx with the two patches applied and
verified it passes.

I wrote tests using HTTP/2 and HTTP/3 based on your test and
verified these tests pass too.
That means we don't need to modify http_v2_module and http_v3_module.

In summary, your patches and tests seem perfect to me.

Thank you,


More information about the nginx-devel mailing list