aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2014-06-26 02:20:09 +0400
committerMaxim Dounin <mdounin@mdounin.ru>2014-06-26 02:20:09 +0400
commit5d477a76feff7b1c583eb40a8d14afca8f6cb3a2 (patch)
tree1a3712bdd81fb0e818af0b72f7d8f045389ae72f /src
parent6c25c848cb2a68eac42b011f33ba9cc186625c50 (diff)
downloadnginx-5d477a76feff7b1c583eb40a8d14afca8f6cb3a2.tar.gz
nginx-5d477a76feff7b1c583eb40a8d14afca8f6cb3a2.zip
Upstream: fixed cache revalidation with SSI.
Previous code in ngx_http_upstream_send_response() used last modified time from r->headers_out.last_modified_time after the header filter chain was already called. At this point, last_modified_time may be already cleared, e.g., with SSI, resulting in incorrect last modified time stored in a cache file. Fix is to introduce u->headers_in.last_modified_time instead.
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_upstream.c34
-rw-r--r--src/http/ngx_http_upstream.h5
2 files changed, 32 insertions, 7 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
index 05766640b..8922dbc8b 100644
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -87,6 +87,8 @@ static ngx_int_t ngx_http_upstream_process_header_line(ngx_http_request_t *r,
ngx_table_elt_t *h, ngx_uint_t offset);
static ngx_int_t ngx_http_upstream_process_content_length(ngx_http_request_t *r,
ngx_table_elt_t *h, ngx_uint_t offset);
+static ngx_int_t ngx_http_upstream_process_last_modified(ngx_http_request_t *r,
+ ngx_table_elt_t *h, ngx_uint_t offset);
static ngx_int_t ngx_http_upstream_process_set_cookie(ngx_http_request_t *r,
ngx_table_elt_t *h, ngx_uint_t offset);
static ngx_int_t
@@ -184,8 +186,7 @@ ngx_http_upstream_header_t ngx_http_upstream_headers_in[] = {
offsetof(ngx_http_headers_out_t, date), 0 },
{ ngx_string("Last-Modified"),
- ngx_http_upstream_process_header_line,
- offsetof(ngx_http_upstream_headers_in_t, last_modified),
+ ngx_http_upstream_process_last_modified, 0,
ngx_http_upstream_copy_last_modified, 0, 0 },
{ ngx_string("ETag"),
@@ -2491,7 +2492,7 @@ ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
}
if (valid) {
- r->cache->last_modified = r->headers_out.last_modified_time;
+ r->cache->last_modified = u->headers_in.last_modified_time;
r->cache->date = now;
r->cache->body_start = (u_short) (u->buffer.pos - u->buffer.start);
@@ -3728,6 +3729,29 @@ ngx_http_upstream_process_content_length(ngx_http_request_t *r,
static ngx_int_t
+ngx_http_upstream_process_last_modified(ngx_http_request_t *r,
+ ngx_table_elt_t *h, ngx_uint_t offset)
+{
+ ngx_http_upstream_t *u;
+
+ u = r->upstream;
+
+ u->headers_in.last_modified = h;
+
+#if (NGX_HTTP_CACHE)
+
+ if (u->cacheable) {
+ u->headers_in.last_modified_time = ngx_http_parse_time(h->value.data,
+ h->value.len);
+ }
+
+#endif
+
+ return NGX_OK;
+}
+
+
+static ngx_int_t
ngx_http_upstream_process_set_cookie(ngx_http_request_t *r, ngx_table_elt_t *h,
ngx_uint_t offset)
{
@@ -4183,8 +4207,8 @@ ngx_http_upstream_copy_last_modified(ngx_http_request_t *r, ngx_table_elt_t *h,
#if (NGX_HTTP_CACHE)
if (r->upstream->cacheable) {
- r->headers_out.last_modified_time = ngx_http_parse_time(h->value.data,
- h->value.len);
+ r->headers_out.last_modified_time =
+ r->upstream->headers_in.last_modified_time;
}
#endif
diff --git a/src/http/ngx_http_upstream.h b/src/http/ngx_http_upstream.h
index 3128ccef0..dafb5a319 100644
--- a/src/http/ngx_http_upstream.h
+++ b/src/http/ngx_http_upstream.h
@@ -246,11 +246,12 @@ typedef struct {
ngx_table_elt_t *content_encoding;
#endif
- off_t content_length_n;
-
ngx_array_t cache_control;
ngx_array_t cookies;
+ off_t content_length_n;
+ time_t last_modified_time;
+
unsigned connection_close:1;
unsigned chunked:1;
} ngx_http_upstream_headers_in_t;