Page MenuHomePhabricator
Paste P6904

uncacheability
ActivePublic

Authored by BBlack on Mar 27 2018, 3:16 PM.
Referenced Files
F16235451: uncacheability
Mar 27 2018, 3:17 PM
F16235415: uncacheability
Mar 27 2018, 3:16 PM
Subscribers
None
Current:
/* Don't cache private, no-cache, no-store objects */
if (beresp.http.Cache-Control ~ "(private|no-cache|no-store)") {
set beresp.ttl = 0s;
// translated to hit-for-pass below
}
[...]
// set a 601s hit-for-pass object based on response conditions in vcl_backend_response:
// Calculated TTL <= 0 + Status < 500 + No underlying cache hit:
// These are generally uncacheable responses. The 5xx exception
// avoids us accidentally replacing a good stale/grace object with
// an hfp (and then repeatedly passing on potentially-cacheable
// content) due to an isolated 5xx response, and the exception for
// underlying cache hits (detected from X-Cache-Int) is to avoid
// creating a persist HFP object when a lower-level varnish
// returned an expired object under grace-mode rules.
if (
beresp.ttl <= 0s
&& beresp.status < 500
&& (!beresp.http.X-Cache-Int || beresp.http.X-Cache-Int !~ " hit")
) {
set beresp.grace = 31s;
set beresp.keep = 0s;
set beresp.http.X-CDIS = "pass";
// XXX: HFP for now, but this requires further work: T180712
<%- if @varnish_version == 5 -%>
return(pass(601s));
<%- else -%>
set beresp.ttl = 601s;
set beresp.uncacheable = true;
return (deliver);
<%- end -%>
}
Straw-person replacement:
if (beresp.status >= 500) {
// XXX decide how we handle 5xx, probably single-miss + coalesce as now?
} else if (beresp.http.Cache-Control ~ "(private|no-cache|no-store|max-age=0|s-maxage=0)") {
// Don't cache private, no-cache, no-store, zero-maxage objects
set beresp.grace = 31s;
set beresp.keep = 0s;
set beresp.http.X-CDIS = "pass";
if (beresp.http.ETag || beresp.http.Last-Modified) {
return(pass(90s)); // HFP
} else {
set beresp.ttl = 90s;
set beresp.uncacheable = true;
return(deliver); // HFM
}
}
// note if CC doesn't indicate uncacheability but ttl happens to be <= 0 (e.g. expiring age, underlying grace hit), we do nothing here and let default miss->coalesce behaviors take over, as it should be.

Event Timeline

BBlack edited the content of this paste. (Show Details)