# HG changeset patch # User Igor Sysoev # Date 1239794472 0 # Node ID d040c37862397c63867f04ce4379df301cf17f5b # Parent ac1e2e199c9ff441ff7939b26cad877e18956bb5 do not pass if-... headers for cacheable responses diff --git a/src/http/modules/ngx_http_proxy_module.c b/src/http/modules/ngx_http_proxy_module.c --- a/src/http/modules/ngx_http_proxy_module.c +++ b/src/http/modules/ngx_http_proxy_module.c @@ -484,6 +484,25 @@ static ngx_keyval_t ngx_http_proxy_head }; +#if (NGX_HTTP_CACHE) + +static ngx_keyval_t ngx_http_proxy_cache_headers[] = { + { ngx_string("Host"), ngx_string("$proxy_host") }, + { ngx_string("Connection"), ngx_string("close") }, + { ngx_string("Keep-Alive"), ngx_string("") }, + { ngx_string("Expect"), ngx_string("") }, + { ngx_string("If-Modified-Since"), ngx_string("") }, + { ngx_string("If-Unmodified-Since"), ngx_string("") }, + { ngx_string("If-Match-None"), ngx_string("") }, + { ngx_string("If-Match"), ngx_string("") }, + { ngx_string("Range"), ngx_string("") }, + { ngx_string("If-Range"), ngx_string("") }, + { ngx_null_string, ngx_null_string } +}; + +#endif + + static ngx_str_t ngx_http_proxy_hide_headers[] = { ngx_string("Date"), ngx_string("Server"), @@ -2286,7 +2305,17 @@ ngx_http_proxy_merge_headers(ngx_conf_t src = conf->headers_source->elts; - for (h = ngx_http_proxy_headers; h->key.len; h++) { +#if (NGX_HTTP_CACHE) + + h = conf->upstream.cache ? ngx_http_proxy_cache_headers: + ngx_http_proxy_headers; +#else + + h = ngx_http_proxy_headers; + +#endif + + while (h->key.len) { for (i = 0; i < conf->headers_source->nelts; i++) { if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) { @@ -2305,7 +2334,7 @@ ngx_http_proxy_merge_headers(ngx_conf_t next: - continue; + h++; }