]> git.kaiwu.me - nginx.git/commitdiff
an intercepted error code was not cached
authorIgor Sysoev <igor@sysoev.ru>
Mon, 19 Jul 2010 15:31:46 +0000 (15:31 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Mon, 19 Jul 2010 15:31:46 +0000 (15:31 +0000)
src/http/ngx_http_upstream.c

index 2f295c2f65e7b88b9dc6fdfec2a6e39c53acb5cc..76e949c2627830a116764735ec906ac783917479 100644 (file)
@@ -1720,6 +1720,24 @@ ngx_http_upstream_intercept_errors(ngx_http_request_t *r,
                 r->headers_out.www_authenticate = h;
             }
 
+#if (NGX_HTTP_CACHE)
+
+            if (u->cacheable && r->cache) {
+                time_t  valid;
+
+                ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+                               "http upstream cache fd: %d", r->cache->file.fd);
+
+                valid = ngx_http_file_cache_valid(u->conf->cache_valid, status);
+
+                if (valid) {
+                    r->cache->valid_sec = ngx_time() + valid;
+                    r->cache->error = status;
+                }
+
+                ngx_http_file_cache_free(r, u->pipe->temp_file);
+            }
+#endif
             ngx_http_upstream_finalize_request(r, u, status);
 
             return NGX_OK;