Changeset 5877:60fde1bc7236 in nginx


Ignore:
Timestamp:
10/27/14 18:13:39 (3 years ago)
Author:
Maxim Dounin <mdounin@…>
Branch:
default
Message:

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.

Location:
src/http
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/http/ngx_http_upstream.c

    r5874 r5877  
    114114    ngx_http_upstream_process_transfer_encoding(ngx_http_request_t *r,
    115115    ngx_table_elt_t *h, ngx_uint_t offset);
     116static ngx_int_t ngx_http_upstream_process_vary(ngx_http_request_t *r,
     117    ngx_table_elt_t *h, ngx_uint_t offset);
    116118static ngx_int_t ngx_http_upstream_copy_header_line(ngx_http_request_t *r,
    117119    ngx_table_elt_t *h, ngx_uint_t offset);
     
    251253                 ngx_http_upstream_ignore_header_line, 0, 0 },
    252254
     255    { ngx_string("Vary"),
     256                 ngx_http_upstream_process_vary, 0,
     257                 ngx_http_upstream_copy_header_line, 0, 0 },
     258
    253259    { ngx_string("X-Powered-By"),
    254260                 ngx_http_upstream_ignore_header_line, 0,
     
    408414    { ngx_string("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL },
    409415    { ngx_string("Set-Cookie"), NGX_HTTP_UPSTREAM_IGN_SET_COOKIE },
     416    { ngx_string("Vary"), NGX_HTTP_UPSTREAM_IGN_VARY },
    410417    { ngx_null_string, 0 }
    411418};
     
    41404147
    41414148static ngx_int_t
     4149ngx_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
     4171static ngx_int_t
    41424172ngx_http_upstream_copy_header_line(ngx_http_request_t *r, ngx_table_elt_t *h,
    41434173    ngx_uint_t offset)
  • src/http/ngx_http_upstream.h

    r5874 r5877  
    5151#define NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING   0x00000080
    5252#define NGX_HTTP_UPSTREAM_IGN_XA_CHARSET     0x00000100
     53#define NGX_HTTP_UPSTREAM_IGN_VARY           0x00000200
    5354
    5455
     
    245246    ngx_table_elt_t                 *www_authenticate;
    246247    ngx_table_elt_t                 *transfer_encoding;
     248    ngx_table_elt_t                 *vary;
    247249
    248250#if (NGX_HTTP_GZIP)
Note: See TracChangeset for help on using the changeset viewer.