Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 3699:b0a0686a85bb
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 19 Jul 2010 09:36:04 +0000 |
parents | d11227f0107f |
children | 7ac6757fa391 |
comparison
equal
deleted
inserted
replaced
3698:d11227f0107f | 3699:b0a0686a85bb |
---|---|
631 | 631 |
632 c = r->cache; | 632 c = r->cache; |
633 | 633 |
634 if (c == NULL) { | 634 if (c == NULL) { |
635 | 635 |
636 rc = ngx_http_test_predicates(r, u->conf->no_cache); | 636 switch (ngx_http_test_predicates(r, u->conf->cache_bypass)) { |
637 if (rc != NGX_OK) { | 637 |
638 return rc; | 638 case NGX_ERROR: |
639 return NGX_ERROR; | |
640 | |
641 case NGX_DECLINED: | |
642 u->cache_status = NGX_HTTP_CACHE_BYPASS; | |
643 return NGX_DECLINED; | |
644 | |
645 default: /* NGX_OK */ | |
646 break; | |
639 } | 647 } |
640 | 648 |
641 if (!(r->method & u->conf->cache_methods)) { | 649 if (!(r->method & u->conf->cache_methods)) { |
642 return NGX_DECLINED; | 650 return NGX_DECLINED; |
643 } | 651 } |
2088 if (r->cache && r->cache->file.fd != NGX_INVALID_FILE) { | 2096 if (r->cache && r->cache->file.fd != NGX_INVALID_FILE) { |
2089 ngx_pool_run_cleanup_file(r->pool, r->cache->file.fd); | 2097 ngx_pool_run_cleanup_file(r->pool, r->cache->file.fd); |
2090 r->cache->file.fd = NGX_INVALID_FILE; | 2098 r->cache->file.fd = NGX_INVALID_FILE; |
2091 } | 2099 } |
2092 | 2100 |
2101 switch (ngx_http_test_predicates(r, u->conf->no_cache)) { | |
2102 | |
2103 case NGX_ERROR: | |
2104 ngx_http_upstream_finalize_request(r, u, 0); | |
2105 return; | |
2106 | |
2107 case NGX_DECLINED: | |
2108 u->cacheable = 0; | |
2109 break; | |
2110 | |
2111 default: /* NGX_OK */ | |
2112 | |
2113 if (u->cache_status == NGX_HTTP_CACHE_BYPASS) { | |
2114 | |
2115 if (ngx_http_file_cache_new(r) != NGX_OK) { | |
2116 ngx_http_upstream_finalize_request(r, u, 0); | |
2117 return; | |
2118 } | |
2119 | |
2120 if (u->create_key(r) != NGX_OK) { | |
2121 ngx_http_upstream_finalize_request(r, u, 0); | |
2122 return; | |
2123 } | |
2124 | |
2125 /* TODO: add keys */ | |
2126 | |
2127 r->cache->min_uses = u->conf->cache_min_uses; | |
2128 r->cache->body_start = u->conf->buffer_size; | |
2129 r->cache->file_cache = u->conf->cache->data; | |
2130 | |
2131 if (ngx_http_file_cache_create(r) != NGX_OK) { | |
2132 ngx_http_upstream_finalize_request(r, u, 0); | |
2133 return; | |
2134 } | |
2135 | |
2136 u->cacheable = 1; | |
2137 } | |
2138 | |
2139 break; | |
2140 } | |
2141 | |
2093 if (u->cacheable) { | 2142 if (u->cacheable) { |
2094 time_t now, valid; | 2143 time_t now, valid; |
2095 | 2144 |
2096 now = ngx_time(); | 2145 now = ngx_time(); |
2097 | 2146 |