Mercurial > hg > nginx
comparison src/http/ngx_http_upstream.c @ 5935:1573fc7875fa
Cache: send conditional requests only for cached 200/206 responses.
RFC7232 says:
The 304 (Not Modified) status code indicates that a conditional GET
or HEAD request has been received and would have resulted in a 200
(OK) response if it were not for the fact that the condition
evaluated to false.
which means that there is no reason to send requests with "If-None-Match"
and/or "If-Modified-Since" headers for responses cached with other status
codes.
Also, sending conditional requests for responses cached with other status
codes could result in a strange behavior, e.g. upstream server returning
304 Not Modified for cached 404 Not Found responses, etc.
Signed-off-by: Piotr Sikora <piotr@cloudflare.com>
author | Piotr Sikora <piotr@cloudflare.com> |
---|---|
date | Wed, 26 Nov 2014 18:35:37 -0800 |
parents | 8dfee01ff0bd |
children | d9025ea1f5a5 |
comparison
equal
deleted
inserted
replaced
5934:2c33ed82cde1 | 5935:1573fc7875fa |
---|---|
2563 r->cache->valid_sec = now + valid; | 2563 r->cache->valid_sec = now + valid; |
2564 } | 2564 } |
2565 } | 2565 } |
2566 | 2566 |
2567 if (valid) { | 2567 if (valid) { |
2568 r->cache->last_modified = u->headers_in.last_modified_time; | |
2569 r->cache->date = now; | 2568 r->cache->date = now; |
2570 r->cache->body_start = (u_short) (u->buffer.pos - u->buffer.start); | 2569 r->cache->body_start = (u_short) (u->buffer.pos - u->buffer.start); |
2571 | 2570 |
2572 if (u->headers_in.etag) { | 2571 if (u->headers_in.status_n == NGX_HTTP_OK |
2573 r->cache->etag = u->headers_in.etag->value; | 2572 || u->headers_in.status_n == NGX_HTTP_PARTIAL_CONTENT) |
2573 { | |
2574 r->cache->last_modified = u->headers_in.last_modified_time; | |
2575 | |
2576 if (u->headers_in.etag) { | |
2577 r->cache->etag = u->headers_in.etag->value; | |
2578 } | |
2574 } | 2579 } |
2575 | 2580 |
2576 ngx_http_file_cache_set_header(r, u->buffer.start); | 2581 ngx_http_file_cache_set_header(r, u->buffer.start); |
2577 | 2582 |
2578 } else { | 2583 } else { |