<div dir="ltr">Hmmm, last_modified_time should have been just last_modifed there.<div>I should resend a patch with this change.<br><div><br></div><div>Regards,</div><div>Thorvaldur<br><div><br></div><div><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 15, 2015 at 3:45 PM, Thorvaldur Thorvaldsson <span dir="ltr"><<a href="mailto:thorvaldur.thorvaldsson@gmail.com" target="_blank">thorvaldur.thorvaldsson@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div># HG changeset patch</div><div># User Thorvaldur Thorvaldsson <<a href="mailto:thorvaldur.thorvaldsson@gmail.com" target="_blank">thorvaldur.thorvaldsson@gmail.com</a>></div><div># Date 1450190015 -3600</div><div># Tue Dec 15 15:33:35 2015 +0100</div><div># Node ID 4a1914481e2bd3eecdc5d23e1386c01e4fb08414</div><div># Parent def9c9c9ae05cfa7467b0ec96e76afa180c23dfb</div><div>Upstream: Cache stale responses if they may be revalidated.</div><div><br></div><div>Previously, the proxy cache would never store stale responses, e.g.,</div><div>when the "Cache-Control" header contained "max-age=0", even if the</div><div>"proxy_cache_revalidate" directive was "on" and the response included</div><div>both an "ETag" and a "Last-Modified" header. This came as a surprise.</div><div><br></div><div>Now, a header like "Cache-Control: max-age=0, must-revalidate" can be</div><div>used to make nginx cache responses that always require revalidation,</div><div>e.g., when authorization is required (and cheap).</div><div><br></div><div>diff -r def9c9c9ae05 -r 4a1914481e2b src/http/ngx_http_file_cache.c</div><div>--- a/src/http/ngx_http_file_cache.c<span style="white-space:pre-wrap"> </span>Sat Dec 12 10:32:58 2015 +0300</div><div>+++ b/src/http/ngx_http_file_cache.c<span style="white-space:pre-wrap"> </span>Tue Dec 15 15:33:35 2015 +0100</div><div>@@ -628,7 +628,7 @@</div><div> </div><div> now = ngx_time();</div><div> </div><div>- if (c->valid_sec < now) {</div><div>+ if (c->valid_sec <= now) {</div><div> </div><div> ngx_shmtx_lock(&cache->shpool->mutex);</div><div> </div><div>@@ -831,7 +831,7 @@</div><div> </div><div> if (fcn->error) {</div><div> </div><div>- if (fcn->valid_sec < ngx_time()) {</div><div>+ if (fcn->valid_sec <= ngx_time()) {</div><div> goto renew;</div><div> }</div><div> </div><div>diff -r def9c9c9ae05 -r 4a1914481e2b src/http/ngx_http_upstream.c</div><div>--- a/src/http/ngx_http_upstream.c<span style="white-space:pre-wrap"> </span>Sat Dec 12 10:32:58 2015 +0300</div><div>+++ b/src/http/ngx_http_upstream.c<span style="white-space:pre-wrap"> </span>Tue Dec 15 15:33:35 2015 +0100</div><div>@@ -2815,11 +2815,15 @@</div><div> valid = ngx_http_file_cache_valid(u->conf->cache_valid,</div><div> u->headers_in.status_n);</div><div> if (valid) {</div><div>- r->cache->valid_sec = now + valid;</div><div>+ valid += now;</div><div>+ r->cache->valid_sec = valid;</div><div> }</div><div> }</div><div> </div><div>- if (valid) {</div><div>+ if (valid > now</div><div>+ || (r->upstream->conf->cache_revalidate</div><div>+ && (u->headers_in.etag || u->headers_in.last_modified_time)))</div><div>+ {</div><div> r->cache->date = now;</div><div> r->cache->body_start = (u_short) (u->buffer.pos - u->buffer.start);</div><div> </div><div>@@ -4272,11 +4276,6 @@</div><div> return NGX_OK;</div><div> }</div><div> </div><div>- if (n == 0) {</div><div>- u->cacheable = 0;</div><div>- return NGX_OK;</div><div>- }</div><div>-</div><div> r->cache->valid_sec = ngx_time() + n;</div><div> }</div><div> #endif</div><div>@@ -4312,7 +4311,7 @@</div><div> </div><div> expires = ngx_parse_http_time(h->value.data, h->value.len);</div><div> </div><div>- if (expires == NGX_ERROR || expires < ngx_time()) {</div><div>+ if (expires == NGX_ERROR) {</div><div> u->cacheable = 0;</div><div> return NGX_OK;</div><div> }</div><div>@@ -4355,10 +4354,6 @@</div><div> n = ngx_atoi(p, len);</div><div> </div><div> switch (n) {</div><div>- case 0:</div><div>- u->cacheable = 0;</div><div>- /* fall through */</div><div>-</div><div> case NGX_ERROR:</div><div> return NGX_OK;</div><div> </div><div><br></div></div>
</blockquote></div><br></div>