comparison src/http/ngx_http_upstream.c @ 5877:60fde1bc7236

Cache: disable caching of responses with Vary (ticket #118). The "proxy_ignore_header" directive now undersands the "Vary" parameter to ignore the header as needed.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 27 Oct 2014 21:13:39 +0300
parents 2aff40b3dea2
children 2c89956b6a76
comparison
equal deleted inserted replaced
5876:973fded4f461 5877:60fde1bc7236
111 static ngx_int_t ngx_http_upstream_process_connection(ngx_http_request_t *r, 111 static ngx_int_t ngx_http_upstream_process_connection(ngx_http_request_t *r,
112 ngx_table_elt_t *h, ngx_uint_t offset); 112 ngx_table_elt_t *h, ngx_uint_t offset);
113 static ngx_int_t 113 static ngx_int_t
114 ngx_http_upstream_process_transfer_encoding(ngx_http_request_t *r, 114 ngx_http_upstream_process_transfer_encoding(ngx_http_request_t *r,
115 ngx_table_elt_t *h, ngx_uint_t offset); 115 ngx_table_elt_t *h, ngx_uint_t offset);
116 static ngx_int_t ngx_http_upstream_process_vary(ngx_http_request_t *r,
117 ngx_table_elt_t *h, ngx_uint_t offset);
116 static ngx_int_t ngx_http_upstream_copy_header_line(ngx_http_request_t *r, 118 static ngx_int_t ngx_http_upstream_copy_header_line(ngx_http_request_t *r,
117 ngx_table_elt_t *h, ngx_uint_t offset); 119 ngx_table_elt_t *h, ngx_uint_t offset);
118 static ngx_int_t 120 static ngx_int_t
119 ngx_http_upstream_copy_multi_header_lines(ngx_http_request_t *r, 121 ngx_http_upstream_copy_multi_header_lines(ngx_http_request_t *r,
120 ngx_table_elt_t *h, ngx_uint_t offset); 122 ngx_table_elt_t *h, ngx_uint_t offset);
248 250
249 { ngx_string("Keep-Alive"), 251 { ngx_string("Keep-Alive"),
250 ngx_http_upstream_ignore_header_line, 0, 252 ngx_http_upstream_ignore_header_line, 0,
251 ngx_http_upstream_ignore_header_line, 0, 0 }, 253 ngx_http_upstream_ignore_header_line, 0, 0 },
252 254
255 { ngx_string("Vary"),
256 ngx_http_upstream_process_vary, 0,
257 ngx_http_upstream_copy_header_line, 0, 0 },
258
253 { ngx_string("X-Powered-By"), 259 { ngx_string("X-Powered-By"),
254 ngx_http_upstream_ignore_header_line, 0, 260 ngx_http_upstream_ignore_header_line, 0,
255 ngx_http_upstream_copy_header_line, 0, 0 }, 261 ngx_http_upstream_copy_header_line, 0, 0 },
256 262
257 { ngx_string("X-Accel-Expires"), 263 { ngx_string("X-Accel-Expires"),
405 { ngx_string("X-Accel-Buffering"), NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING }, 411 { ngx_string("X-Accel-Buffering"), NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING },
406 { ngx_string("X-Accel-Charset"), NGX_HTTP_UPSTREAM_IGN_XA_CHARSET }, 412 { ngx_string("X-Accel-Charset"), NGX_HTTP_UPSTREAM_IGN_XA_CHARSET },
407 { ngx_string("Expires"), NGX_HTTP_UPSTREAM_IGN_EXPIRES }, 413 { ngx_string("Expires"), NGX_HTTP_UPSTREAM_IGN_EXPIRES },
408 { ngx_string("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL }, 414 { ngx_string("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL },
409 { ngx_string("Set-Cookie"), NGX_HTTP_UPSTREAM_IGN_SET_COOKIE }, 415 { ngx_string("Set-Cookie"), NGX_HTTP_UPSTREAM_IGN_SET_COOKIE },
416 { ngx_string("Vary"), NGX_HTTP_UPSTREAM_IGN_VARY },
410 { ngx_null_string, 0 } 417 { ngx_null_string, 0 }
411 }; 418 };
412 419
413 420
414 ngx_int_t 421 ngx_int_t
4137 return NGX_OK; 4144 return NGX_OK;
4138 } 4145 }
4139 4146
4140 4147
4141 static ngx_int_t 4148 static ngx_int_t
4149 ngx_http_upstream_process_vary(ngx_http_request_t *r,
4150 ngx_table_elt_t *h, ngx_uint_t offset)
4151 {
4152 ngx_http_upstream_t *u;
4153
4154 u = r->upstream;
4155 u->headers_in.vary = h;
4156
4157 #if (NGX_HTTP_CACHE)
4158
4159 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_VARY) {
4160 return NGX_OK;
4161 }
4162
4163 u->cacheable = 0;
4164
4165 #endif
4166
4167 return NGX_OK;
4168 }
4169
4170
4171 static ngx_int_t
4142 ngx_http_upstream_copy_header_line(ngx_http_request_t *r, ngx_table_elt_t *h, 4172 ngx_http_upstream_copy_header_line(ngx_http_request_t *r, ngx_table_elt_t *h,
4143 ngx_uint_t offset) 4173 ngx_uint_t offset)
4144 { 4174 {
4145 ngx_table_elt_t *ho, **ph; 4175 ngx_table_elt_t *ho, **ph;
4146 4176