Hello! On Wed, Dec 16, 2015 at 03:37:27PM +0100, Thorvaldur Thorvaldsson wrote:
> # HG changeset patch > # User Thorvaldur Thorvaldsson <thorvaldur.thorvalds...@gmail.com> > # Date 1450190015 -3600 > # Tue Dec 15 15:33:35 2015 +0100 > # Node ID 2c1f00c7f857c12587f0ac47323f04c6a881843a > # Parent def9c9c9ae05cfa7467b0ec96e76afa180c23dfb > Upstream: Cache stale responses if they may be revalidated. > > Previously, the proxy cache would never store stale responses, e.g., > when the "Cache-Control" header contained "max-age=0", even if the > "proxy_cache_revalidate" directive was "on" and the response included > both an "ETag" and a "Last-Modified" header. This came as a surprise. > > Now, a header like "Cache-Control: max-age=0, must-revalidate" can be > used along with an ETag/Last-Modified header to make nginx cache > responses that always require revalidation, e.g., when authorization is > required (and cheap). [...] > diff -r def9c9c9ae05 -r 2c1f00c7f857 src/http/ngx_http_upstream.c > --- a/src/http/ngx_http_upstream.c Sat Dec 12 10:32:58 2015 +0300 > +++ b/src/http/ngx_http_upstream.c Tue Dec 15 15:33:35 2015 +0100 > @@ -2815,11 +2815,16 @@ > valid = ngx_http_file_cache_valid(u->conf->cache_valid, > u->headers_in.status_n); > if (valid) { > - r->cache->valid_sec = now + valid; > + valid += now; > + r->cache->valid_sec = valid; > } > } > > - if (valid) { > + if (valid > now > + || (r->upstream->conf->cache_revalidate > + && (u->headers_in.etag > + || u->headers_in.last_modified_time != -1))) > + { > r->cache->date = now; > r->cache->body_start = (u_short) (u->buffer.pos - > u->buffer.start); As far as I see, this still allows caching of all responses, even ones without Cache-Control/Expires/X-Accel-Expires and proxy_cache_valid configured. This is not something that should happen because of revalidation enabled. You may want to rethink how the patch is expected to work. [...] -- Maxim Dounin http://nginx.org/ _______________________________________________ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel