comparison src/http/ngx_http_cache.h @ 6905:9a9e13686869

Cache: support for stale-while-revalidate and stale-if-error. Previously, there was no way to enable the proxy_cache_use_stale behavior by reading the backend response. Now, stale-while-revalidate and stale-if-error Cache-Control extensions (RFC 5861) are supported. They specify, how long a stale response can be used when a cache entry is being updated, or in case of an error.
author Roman Arutyunyan <arut@nginx.com>
date Thu, 22 Dec 2016 14:25:34 +0300
parents 1a917932db96
children 1aeaae6e9446
comparison
equal deleted inserted replaced
6904:5e2423bce883 6905:9a9e13686869
25 25
26 #define NGX_HTTP_CACHE_KEY_LEN 16 26 #define NGX_HTTP_CACHE_KEY_LEN 16
27 #define NGX_HTTP_CACHE_ETAG_LEN 42 27 #define NGX_HTTP_CACHE_ETAG_LEN 42
28 #define NGX_HTTP_CACHE_VARY_LEN 42 28 #define NGX_HTTP_CACHE_VARY_LEN 42
29 29
30 #define NGX_HTTP_CACHE_VERSION 3 30 #define NGX_HTTP_CACHE_VERSION 4
31 31
32 32
33 typedef struct { 33 typedef struct {
34 ngx_uint_t status; 34 ngx_uint_t status;
35 time_t valid; 35 time_t valid;
69 u_char key[NGX_HTTP_CACHE_KEY_LEN]; 69 u_char key[NGX_HTTP_CACHE_KEY_LEN];
70 u_char main[NGX_HTTP_CACHE_KEY_LEN]; 70 u_char main[NGX_HTTP_CACHE_KEY_LEN];
71 71
72 ngx_file_uniq_t uniq; 72 ngx_file_uniq_t uniq;
73 time_t valid_sec; 73 time_t valid_sec;
74 time_t updating_sec;
75 time_t error_sec;
74 time_t last_modified; 76 time_t last_modified;
75 time_t date; 77 time_t date;
76 78
77 ngx_str_t etag; 79 ngx_str_t etag;
78 ngx_str_t vary; 80 ngx_str_t vary;
112 unsigned exists:1; 114 unsigned exists:1;
113 unsigned temp_file:1; 115 unsigned temp_file:1;
114 unsigned purged:1; 116 unsigned purged:1;
115 unsigned reading:1; 117 unsigned reading:1;
116 unsigned secondary:1; 118 unsigned secondary:1;
119
120 unsigned stale_updating:1;
121 unsigned stale_error:1;
117 }; 122 };
118 123
119 124
120 typedef struct { 125 typedef struct {
121 ngx_uint_t version; 126 ngx_uint_t version;
122 time_t valid_sec; 127 time_t valid_sec;
128 time_t updating_sec;
129 time_t error_sec;
123 time_t last_modified; 130 time_t last_modified;
124 time_t date; 131 time_t date;
125 uint32_t crc32; 132 uint32_t crc32;
126 u_short valid_msec; 133 u_short valid_msec;
127 u_short header_start; 134 u_short header_start;