diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2010-07-19 09:36:04 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2010-07-19 09:36:04 +0000 |
| commit | f7d659aa525f162ef417ab7a01de5de8cb668cf0 (patch) | |
| tree | fd70a240ae272fcb512630df3bc9c5380a013aa2 /src/http/ngx_http_upstream.c | |
| parent | 6a47b4323461cfa8da0d401276fc6c840764006e (diff) | |
| download | nginx-f7d659aa525f162ef417ab7a01de5de8cb668cf0.tar.gz nginx-f7d659aa525f162ef417ab7a01de5de8cb668cf0.tar.bz2 | |
proxy_cache_pass, fastcgi_cache_bypass, uwsgi_cache_bypass, scgi_cache_bypass
Diffstat (limited to 'src/http/ngx_http_upstream.c')
| -rw-r--r-- | src/http/ngx_http_upstream.c | 55 |
1 files changed, 52 insertions, 3 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index 51c34c8a9..8ee5aeabd 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -633,9 +633,17 @@ ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u) if (c == NULL) { - rc = ngx_http_test_predicates(r, u->conf->no_cache); - if (rc != NGX_OK) { - return rc; + switch (ngx_http_test_predicates(r, u->conf->cache_bypass)) { + + case NGX_ERROR: + return NGX_ERROR; + + case NGX_DECLINED: + u->cache_status = NGX_HTTP_CACHE_BYPASS; + return NGX_DECLINED; + + default: /* NGX_OK */ + break; } if (!(r->method & u->conf->cache_methods)) { @@ -2090,6 +2098,47 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u) r->cache->file.fd = NGX_INVALID_FILE; } + switch (ngx_http_test_predicates(r, u->conf->no_cache)) { + + case NGX_ERROR: + ngx_http_upstream_finalize_request(r, u, 0); + return; + + case NGX_DECLINED: + u->cacheable = 0; + break; + + default: /* NGX_OK */ + + if (u->cache_status == NGX_HTTP_CACHE_BYPASS) { + + if (ngx_http_file_cache_new(r) != NGX_OK) { + ngx_http_upstream_finalize_request(r, u, 0); + return; + } + + if (u->create_key(r) != NGX_OK) { + ngx_http_upstream_finalize_request(r, u, 0); + return; + } + + /* TODO: add keys */ + + r->cache->min_uses = u->conf->cache_min_uses; + r->cache->body_start = u->conf->buffer_size; + r->cache->file_cache = u->conf->cache->data; + + if (ngx_http_file_cache_create(r) != NGX_OK) { + ngx_http_upstream_finalize_request(r, u, 0); + return; + } + + u->cacheable = 1; + } + + break; + } + if (u->cacheable) { time_t now, valid; |
