comparison src/http/ngx_http_cache.h @ 5878:2c89956b6a76

Cache: hash of Vary headers now stored in cache. To cache responses with Vary, we now calculate hash of headers listed in Vary, and return the response from cache only if new request headers match. As of now, only one variant of the same resource can be stored in cache.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 27 Oct 2014 21:13:58 +0300
parents 44b9ab7752e3
children c525c0454aa5
comparison
equal deleted inserted replaced
5877:60fde1bc7236 5878:2c89956b6a76
23 #define NGX_HTTP_CACHE_HIT 7 23 #define NGX_HTTP_CACHE_HIT 7
24 #define NGX_HTTP_CACHE_SCARCE 8 24 #define NGX_HTTP_CACHE_SCARCE 8
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 29
29 #define NGX_HTTP_CACHE_VERSION 2 30 #define NGX_HTTP_CACHE_VERSION 3
30 31
31 32
32 typedef struct { 33 typedef struct {
33 ngx_uint_t status; 34 ngx_uint_t status;
34 time_t valid; 35 time_t valid;
69 time_t valid_sec; 70 time_t valid_sec;
70 time_t last_modified; 71 time_t last_modified;
71 time_t date; 72 time_t date;
72 73
73 ngx_str_t etag; 74 ngx_str_t etag;
75 ngx_str_t vary;
76 u_char variant[NGX_HTTP_CACHE_KEY_LEN];
74 77
75 size_t header_start; 78 size_t header_start;
76 size_t body_start; 79 size_t body_start;
77 off_t length; 80 off_t length;
78 off_t fs_size; 81 off_t fs_size;
110 u_short valid_msec; 113 u_short valid_msec;
111 u_short header_start; 114 u_short header_start;
112 u_short body_start; 115 u_short body_start;
113 u_char etag_len; 116 u_char etag_len;
114 u_char etag[NGX_HTTP_CACHE_ETAG_LEN]; 117 u_char etag[NGX_HTTP_CACHE_ETAG_LEN];
118 u_char vary_len;
119 u_char vary[NGX_HTTP_CACHE_VARY_LEN];
120 u_char variant[NGX_HTTP_CACHE_KEY_LEN];
115 } ngx_http_file_cache_header_t; 121 } ngx_http_file_cache_header_t;
116 122
117 123
118 typedef struct { 124 typedef struct {
119 ngx_rbtree_t rbtree; 125 ngx_rbtree_t rbtree;