]> git.kaiwu.me - nginx.git/commitdiff
Upstream: preset some cache configuration when bypassing.
authorValentin Bartenev <vbart@nginx.com>
Mon, 22 Dec 2014 09:59:06 +0000 (12:59 +0300)
committerValentin Bartenev <vbart@nginx.com>
Mon, 22 Dec 2014 09:59:06 +0000 (12:59 +0300)
No functional changes.

src/http/ngx_http_upstream.c

index b2066a3ef06bb73d4f080f9eb4bca68845f9e0ed..4e71af010ed3da5e37fb63afe5807fa25915a45a 100644 (file)
@@ -763,6 +763,12 @@ ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u)
 
         u->cacheable = 1;
 
+        c = r->cache;
+
+        c->body_start = u->conf->buffer_size;
+        c->min_uses = u->conf->cache_min_uses;
+        c->file_cache = u->conf->cache_zone->data;
+
         switch (ngx_http_test_predicates(r, u->conf->cache_bypass)) {
 
         case NGX_ERROR:
@@ -776,12 +782,6 @@ ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u)
             break;
         }
 
-        c = r->cache;
-
-        c->min_uses = u->conf->cache_min_uses;
-        c->body_start = u->conf->buffer_size;
-        c->file_cache = u->conf->cache_zone->data;
-
         c->lock = u->conf->cache_lock;
         c->lock_timeout = u->conf->cache_lock_timeout;
         c->lock_age = u->conf->cache_lock_age;
@@ -2536,9 +2536,7 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
 
         if (u->cache_status == NGX_HTTP_CACHE_BYPASS) {
 
-            r->cache->min_uses = u->conf->cache_min_uses;
-            r->cache->body_start = u->conf->buffer_size;
-            r->cache->file_cache = u->conf->cache_zone->data;
+            /* create cache if previously bypassed */
 
             if (ngx_http_file_cache_create(r) != NGX_OK) {
                 ngx_http_upstream_finalize_request(r, u, NGX_ERROR);