Mercurial > hg > nginx
comparison src/http/modules/ngx_http_proxy_module.c @ 2672:b212066acf50
proxy_cache_key
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 06 Apr 2009 08:58:44 +0000 |
parents | 377698b60999 |
children | d040c3786239 |
comparison
equal
deleted
inserted
replaced
2671:627dee566f6c | 2672:b212066acf50 |
---|---|
61 ngx_str_t body_source; | 61 ngx_str_t body_source; |
62 | 62 |
63 ngx_str_t method; | 63 ngx_str_t method; |
64 ngx_str_t location; | 64 ngx_str_t location; |
65 ngx_str_t url; | 65 ngx_str_t url; |
66 | |
67 #if (NGX_HTTP_CACHE) | |
68 ngx_http_complex_value_t cache_key; | |
69 #endif | |
66 | 70 |
67 ngx_http_proxy_vars_t vars; | 71 ngx_http_proxy_vars_t vars; |
68 | 72 |
69 ngx_flag_t redirect; | 73 ngx_flag_t redirect; |
70 | 74 |
130 static char *ngx_http_proxy_store(ngx_conf_t *cf, ngx_command_t *cmd, | 134 static char *ngx_http_proxy_store(ngx_conf_t *cf, ngx_command_t *cmd, |
131 void *conf); | 135 void *conf); |
132 #if (NGX_HTTP_CACHE) | 136 #if (NGX_HTTP_CACHE) |
133 static char *ngx_http_proxy_cache(ngx_conf_t *cf, ngx_command_t *cmd, | 137 static char *ngx_http_proxy_cache(ngx_conf_t *cf, ngx_command_t *cmd, |
134 void *conf); | 138 void *conf); |
139 static char *ngx_http_proxy_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, | |
140 void *conf); | |
135 #endif | 141 #endif |
136 | 142 |
137 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data); | 143 static char *ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data); |
138 | 144 |
139 static char *ngx_http_proxy_upstream_max_fails_unsupported(ngx_conf_t *cf, | 145 static char *ngx_http_proxy_upstream_max_fails_unsupported(ngx_conf_t *cf, |
321 #if (NGX_HTTP_CACHE) | 327 #if (NGX_HTTP_CACHE) |
322 | 328 |
323 { ngx_string("proxy_cache"), | 329 { ngx_string("proxy_cache"), |
324 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | 330 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, |
325 ngx_http_proxy_cache, | 331 ngx_http_proxy_cache, |
332 NGX_HTTP_LOC_CONF_OFFSET, | |
333 0, | |
334 NULL }, | |
335 | |
336 { ngx_string("proxy_cache_key"), | |
337 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, | |
338 ngx_http_proxy_cache_key, | |
326 NGX_HTTP_LOC_CONF_OFFSET, | 339 NGX_HTTP_LOC_CONF_OFFSET, |
327 0, | 340 0, |
328 NULL }, | 341 NULL }, |
329 | 342 |
330 { ngx_string("proxy_cache_path"), | 343 { ngx_string("proxy_cache_path"), |
711 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); | 724 ctx = ngx_http_get_module_ctx(r, ngx_http_proxy_module); |
712 | 725 |
713 key = ngx_array_push(&r->cache->keys); | 726 key = ngx_array_push(&r->cache->keys); |
714 if (key == NULL) { | 727 if (key == NULL) { |
715 return NGX_ERROR; | 728 return NGX_ERROR; |
729 } | |
730 | |
731 if (plcf->cache_key.value.len) { | |
732 | |
733 if (ngx_http_complex_value(r, &plcf->cache_key, key) != NGX_OK) { | |
734 return NGX_ERROR; | |
735 } | |
736 | |
737 return NGX_OK; | |
716 } | 738 } |
717 | 739 |
718 *key = ctx->vars.key_start; | 740 *key = ctx->vars.key_start; |
719 | 741 |
720 key = ngx_array_push(&r->cache->keys); | 742 key = ngx_array_push(&r->cache->keys); |
2066 } | 2088 } |
2067 | 2089 |
2068 ngx_conf_merge_ptr_value(conf->upstream.cache_valid, | 2090 ngx_conf_merge_ptr_value(conf->upstream.cache_valid, |
2069 prev->upstream.cache_valid, NULL); | 2091 prev->upstream.cache_valid, NULL); |
2070 | 2092 |
2093 if (conf->cache_key.value.data == NULL) { | |
2094 conf->cache_key = prev->cache_key; | |
2095 } | |
2096 | |
2071 #endif | 2097 #endif |
2072 | 2098 |
2073 if (conf->method.len == 0) { | 2099 if (conf->method.len == 0) { |
2074 conf->method = prev->method; | 2100 conf->method = prev->method; |
2075 | 2101 |
2736 } | 2762 } |
2737 | 2763 |
2738 return NGX_CONF_OK; | 2764 return NGX_CONF_OK; |
2739 } | 2765 } |
2740 | 2766 |
2767 | |
2768 static char * | |
2769 ngx_http_proxy_cache_key(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
2770 { | |
2771 ngx_http_proxy_loc_conf_t *plcf = conf; | |
2772 | |
2773 ngx_str_t *value; | |
2774 ngx_http_compile_complex_value_t ccv; | |
2775 | |
2776 value = cf->args->elts; | |
2777 | |
2778 if (plcf->cache_key.value.len) { | |
2779 return "is duplicate"; | |
2780 } | |
2781 | |
2782 ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t)); | |
2783 | |
2784 ccv.cf = cf; | |
2785 ccv.value = &value[1]; | |
2786 ccv.complex_value = &plcf->cache_key; | |
2787 | |
2788 if (ngx_http_compile_complex_value(&ccv) != NGX_OK) { | |
2789 return NGX_CONF_ERROR; | |
2790 } | |
2791 | |
2792 return NGX_CONF_OK; | |
2793 } | |
2794 | |
2741 #endif | 2795 #endif |
2742 | 2796 |
2743 | 2797 |
2744 static char * | 2798 static char * |
2745 ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) | 2799 ngx_http_proxy_lowat_check(ngx_conf_t *cf, void *post, void *data) |