Mercurial > hg > nginx
comparison src/http/modules/ngx_http_not_modified_filter_module.c @ 5735:5fb1e57c758a
Entity tags: explicit flag to skip not modified filter.
Previously, last_modified_time was tested against -1 to check if the
not modified filter should be skipped. Notably, this prevented nginx
from additional If-Modified-Since (et al.) checks on proxied responses.
Such behaviour is suboptimal in some cases though, as checks are always
skipped on responses from a cache with ETag only (without Last-Modified),
resulting in If-None-Match being ignored in such cases. Additionally,
it was not possible to return 412 from the If-Unmodified-Since if last
modification time was not known for some reason.
This change introduces explicit r->disable_not_modified flag instead,
which is set by ngx_http_upstream_process_headers().
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 26 Jun 2014 02:27:11 +0400 |
parents | af229f8cf987 |
children | 8b6fa4842133 |
comparison
equal
deleted
inserted
replaced
5734:af229f8cf987 | 5735:5fb1e57c758a |
---|---|
54 static ngx_int_t | 54 static ngx_int_t |
55 ngx_http_not_modified_header_filter(ngx_http_request_t *r) | 55 ngx_http_not_modified_header_filter(ngx_http_request_t *r) |
56 { | 56 { |
57 if (r->headers_out.status != NGX_HTTP_OK | 57 if (r->headers_out.status != NGX_HTTP_OK |
58 || r != r->main | 58 || r != r->main |
59 || r->headers_out.last_modified_time == -1) | 59 || r->disable_not_modified) |
60 { | 60 { |
61 return ngx_http_next_header_filter(r); | 61 return ngx_http_next_header_filter(r); |
62 } | 62 } |
63 | 63 |
64 if (r->headers_in.if_unmodified_since | 64 if (r->headers_in.if_unmodified_since |
112 static ngx_uint_t | 112 static ngx_uint_t |
113 ngx_http_test_if_unmodified(ngx_http_request_t *r) | 113 ngx_http_test_if_unmodified(ngx_http_request_t *r) |
114 { | 114 { |
115 time_t iums; | 115 time_t iums; |
116 | 116 |
117 if (r->headers_out.last_modified_time == (time_t) -1) { | |
118 return 0; | |
119 } | |
120 | |
117 iums = ngx_http_parse_time(r->headers_in.if_unmodified_since->value.data, | 121 iums = ngx_http_parse_time(r->headers_in.if_unmodified_since->value.data, |
118 r->headers_in.if_unmodified_since->value.len); | 122 r->headers_in.if_unmodified_since->value.len); |
119 | 123 |
120 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 124 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
121 "http iums:%T lm:%T", iums, r->headers_out.last_modified_time); | 125 "http iums:%T lm:%T", iums, r->headers_out.last_modified_time); |
131 static ngx_uint_t | 135 static ngx_uint_t |
132 ngx_http_test_if_modified(ngx_http_request_t *r) | 136 ngx_http_test_if_modified(ngx_http_request_t *r) |
133 { | 137 { |
134 time_t ims; | 138 time_t ims; |
135 ngx_http_core_loc_conf_t *clcf; | 139 ngx_http_core_loc_conf_t *clcf; |
140 | |
141 if (r->headers_out.last_modified_time == (time_t) -1) { | |
142 return 1; | |
143 } | |
136 | 144 |
137 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 145 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
138 | 146 |
139 if (clcf->if_modified_since == NGX_HTTP_IMS_OFF) { | 147 if (clcf->if_modified_since == NGX_HTTP_IMS_OFF) { |
140 return 1; | 148 return 1; |