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

Hiroaki Nakamura hnakamur at gmail.com
Thu Jun 20 11:39:51 UTC 2024


# HG changeset patch
# User Hiroaki Nakamura <hnakamur at gmail.com>
# Date 1718882809 -32400
#      Thu Jun 20 20:26:49 2024 +0900
# Branch correct_age
# Node ID 56187d3f24d45b895f6ddb86495cbaf098540107
# Parent  c81df54e3d0333c26d4296792dc0df767b386f91
Save response time and corrected initial age to file cache header.

diff -r c81df54e3d03 -r 56187d3f24d4 src/http/ngx_http_cache.h
--- a/src/http/ngx_http_cache.h Thu Jun 20 20:26:41 2024 +0900
+++ b/src/http/ngx_http_cache.h Thu Jun 20 20:26:49 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 c81df54e3d03 -r 56187d3f24d4 src/http/ngx_http_file_cache.c
--- a/src/http/ngx_http_file_cache.c    Thu Jun 20 20:26:41 2024 +0900
+++ b/src/http/ngx_http_file_cache.c    Thu Jun 20 20:26:49 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