comparison 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
comparison
equal deleted inserted replaced
9305:8cdab3d89c44 9306:e46e1ea89ccd
89 offsetof(ngx_http_headers_out_t, last_modified), 89 offsetof(ngx_http_headers_out_t, last_modified),
90 ngx_http_set_last_modified }, 90 ngx_http_set_last_modified },
91 91
92 { ngx_string("ETag"), 92 { ngx_string("ETag"),
93 offsetof(ngx_http_headers_out_t, etag), 93 offsetof(ngx_http_headers_out_t, etag),
94 ngx_http_set_response_header },
95
96 { ngx_string("Age"),
97 offsetof(ngx_http_headers_out_t, age),
94 ngx_http_set_response_header }, 98 ngx_http_set_response_header },
95 99
96 { ngx_null_string, 0, NULL } 100 { ngx_null_string, 0, NULL }
97 }; 101 };
98 102
350 if (expires == NGX_HTTP_EXPIRES_OFF) { 354 if (expires == NGX_HTTP_EXPIRES_OFF) {
351 return NGX_OK; 355 return NGX_OK;
352 } 356 }
353 } 357 }
354 358
359 if (r->headers_out.age) {
360 r->headers_out.age->hash = 0;
361 r->headers_out.age = NULL;
362 }
363
355 e = r->headers_out.expires; 364 e = r->headers_out.expires;
356 365
357 if (e == NULL) { 366 if (e == NULL) {
358 367
359 e = ngx_list_push(&r->headers_out.headers); 368 e = ngx_list_push(&r->headers_out.headers);