[PATCH 2 of 3] Save response time and corrected initial age to file cache header

Hiroaki Nakamura hnakamur at gmail.com
Fri Jun 14 07:29:19 UTC 2024


# HG changeset patch
# User Hiroaki Nakamura <hnakamur at gmail.com>
# Date 1718345850 -32400
#      Fri Jun 14 15:17:30 2024 +0900
# Branch correct_age
# Node ID 51355c41fc134954e58b1534d232291d70252be7
# Parent  493817cf38580a71430f9c1293e29bdfbf243075
Save response time and corrected initial age to file cache header.

diff -r 493817cf3858 -r 51355c41fc13 src/http/ngx_http_cache.h
--- a/src/http/ngx_http_cache.h Fri Jun 14 15:17:24 2024 +0900
+++ b/src/http/ngx_http_cache.h Fri Jun 14 15:17:30 2024 +0900
@@ -27,7 +27,7 @@
 #define NGX_HTTP_CACHE_ETAG_LEN      128
 #define NGX_HTTP_CACHE_VARY_LEN      128

-#define NGX_HTTP_CACHE_VERSION       5
+#define NGX_HTTP_CACHE_VERSION       6


 typedef struct {
@@ -145,6 +145,8 @@
     u_char                           vary_len;
     u_char                           vary[NGX_HTTP_CACHE_VARY_LEN];
     u_char                           variant[NGX_HTTP_CACHE_KEY_LEN];
+    time_t                           response_time;
+    time_t                           corrected_initial_age;
 } ngx_http_file_cache_header_t;


diff -r 493817cf3858 -r 51355c41fc13 src/http/ngx_http_file_cache.c
--- a/src/http/ngx_http_file_cache.c    Fri Jun 14 15:17:24 2024 +0900
+++ b/src/http/ngx_http_file_cache.c    Fri Jun 14 15:17:30 2024 +0900
@@ -627,6 +627,8 @@
     c->body_start = h->body_start;
     c->etag.len = h->etag_len;
     c->etag.data = h->etag;
+    c->response_time = h->response_time;
+    c->corrected_initial_age = h->corrected_initial_age;

     r->cached = 1;

@@ -1330,6 +1332,8 @@
     h->valid_msec = (u_short) c->valid_msec;
     h->header_start = (u_short) c->header_start;
     h->body_start = (u_short) c->body_start;
+    h->response_time = c->response_time;
+    h->corrected_initial_age = c->corrected_initial_age;

     if (c->etag.len <= NGX_HTTP_CACHE_ETAG_LEN) {
         h->etag_len = (u_char) c->etag.len;
@@ -1594,6 +1598,8 @@
     h.valid_msec = (u_short) c->valid_msec;
     h.header_start = (u_short) c->header_start;
     h.body_start = (u_short) c->body_start;
+    h.response_time = c->response_time;
+    h.corrected_initial_age = c->corrected_initial_age;

     if (c->etag.len <= NGX_HTTP_CACHE_ETAG_LEN) {
         h.etag_len = (u_char) c->etag.len;


More information about the nginx-devel mailing list