[PATCH] Cache: re-fetch responses cached with invalid HTTP header
Piotr Sikora
piotr at cloudflare.com
Fri Jul 10 22:09:58 UTC 2015
# HG changeset patch
# User Piotr Sikora <piotr at cloudflare.com>
# Date 1436566103 25200
# Fri Jul 10 15:08:23 2015 -0700
# Node ID 596ce484f8b5519df8803754f093e37b26806699
# Parent dcae651b2a0cbd3de2f1fd5cf5b8c72627db94fd
Cache: re-fetch responses cached with invalid HTTP header.
Previously, such responses would be read into the buffer, fail,
then nginx would connect to the upstream to fetch new response,
but that response would be read into the same buffer, after the
invalid response, leading to a persistent failure state.
This patch resets buffer, so that the new response can be used.
Signed-off-by: Piotr Sikora <piotr at cloudflare.com>
diff -r dcae651b2a0c -r 596ce484f8b5 src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c Tue Jul 07 16:38:49 2015 +0300
+++ b/src/http/ngx_http_upstream.c Fri Jul 10 15:08:23 2015 -0700
@@ -843,6 +843,20 @@
return rc;
}
+ u->cache_status = NGX_HTTP_CACHE_MISS;
+
+ /* fall through */
+
+ case NGX_DECLINED:
+
+ if ((size_t) (u->buffer.end - u->buffer.start) < u->conf->buffer_size) {
+ u->buffer.start = NULL;
+
+ } else {
+ u->buffer.pos = u->buffer.start + c->header_start;
+ u->buffer.last = u->buffer.pos;
+ }
+
break;
case NGX_HTTP_CACHE_STALE:
@@ -853,18 +867,6 @@
break;
- case NGX_DECLINED:
-
- if ((size_t) (u->buffer.end - u->buffer.start) < u->conf->buffer_size) {
- u->buffer.start = NULL;
-
- } else {
- u->buffer.pos = u->buffer.start + c->header_start;
- u->buffer.last = u->buffer.pos;
- }
-
- break;
-
case NGX_HTTP_CACHE_SCARCE:
u->cacheable = 0;
More information about the nginx-devel
mailing list