Mercurial > hg > nginx
diff src/http/modules/ngx_http_headers_filter_module.c @ 9306:e46e1ea89ccd
Upstream: $upstream_cache_age variable.
The variable reflects response age, including the time spent in the
cache and the upstream response age as obtained from the "Age" header.
If the response wasn't cached, the variable reflects the "Age" header
of the upstream response.
If the intended use case is to cache responses as per HTTP/1.1 caching
model, the $upstream_cache_age variable can be used to provide the "Age"
header with the "add_header" directive, such as:
add_header Age $upstream_cache_age;
This now removes the "Age" header if it was present.
Further, the "expires" directives now removes the "Age" header if it
was present in the response, as the "expires" directive assumes zero
age when it adds "Expires" and "Cache-Control" headers.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 18 Jul 2024 19:39:45 +0300 |
parents | e64a1f32065b |
children |
line wrap: on
line diff
--- a/src/http/modules/ngx_http_headers_filter_module.c +++ b/src/http/modules/ngx_http_headers_filter_module.c @@ -93,6 +93,10 @@ static ngx_http_set_header_t ngx_http_s offsetof(ngx_http_headers_out_t, etag), ngx_http_set_response_header }, + { ngx_string("Age"), + offsetof(ngx_http_headers_out_t, age), + ngx_http_set_response_header }, + { ngx_null_string, 0, NULL } }; @@ -352,6 +356,11 @@ ngx_http_set_expires(ngx_http_request_t } } + if (r->headers_out.age) { + r->headers_out.age->hash = 0; + r->headers_out.age = NULL; + } + e = r->headers_out.expires; if (e == NULL) {