<div dir="auto"><div>man vcl<div dir="auto"><br><div dir="auto">bereq is filtered to avoid side effects of the client forcing the ttl to the backed.</div><div dir="auto"><br></div><div dir="auto">Anyway, by the time you have access to bereq, it's too late for you since the decision to go to the backend has already been been made.</div><div dir="auto"><br><div data-smartmail="gmail_signature" dir="auto">-- <br>Guillaume Quintard </div></div></div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jul 31, 2017 19:56, "Martynas Jusevičius" <<a href="mailto:martynas@atomgraph.com">martynas@atomgraph.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks. What was mostly unclear to me is passing the req header value all the way to where it's used to set TTL.<br><br>Why doesn't bereq contain the req headers? At least Cache-Control is gone.<br><br>But I guess that can be done using obj.ttl, which I didn't know about. Any documentation on that?<div class="elided-text"><br><div class="gmail_quote"><div dir="ltr">On Mon, 31 Jul 2017 at 18.38, Guillaume Quintard <<a href="mailto:guillaume@varnish-software.com" target="_blank">guillaume@varnish-software.<wbr>com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">On github I pointed to the doc explaining how you can return(fetch) to ignore a cached object, possibly based on ttl, so you already have half the answer.<div dir="auto"><br></div><div dir="auto">The other part of the equation is just converting req.http.cache-control to a duration and comparing that to obj.ttl. It will be similar to what you have done on v3.<br><br><div data-smartmail="gmail_signature" dir="auto">-- <br>Guillaume Quintard </div></div></div><div class="gmail_extra"><br><div class="gmail_quote"></div></div><div class="gmail_extra"><div class="gmail_quote">On Jul 31, 2017 18:25, "Martynas Jusevičius" <<a href="mailto:martynas@atomgraph.com" target="_blank">martynas@atomgraph.com</a>> wrote:<br type="attribution"></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I have been reading quite a bit about Varnish and VCL but found almost no examples with Cache-Control coming from the client request [1].</div><div><br></div><div>What I want to achieve: if the client sends Cache-Control: max-age=60, TTL becomes 60 s. If the cache hit is fresher than 60 s, deliver it, otherwise fetch a new response from backend (I hope I'm not misusing the VCL terms here) *and* cache it.</div><div><br></div><div>I had hacked this together in the vcl_fetch section in Varnish 3.x by setting the req.http.Cache-Control max-age value as beresp.ttl, but vcl_fetch is gone in Varnish 4.x.</div><div><br></div><div>I have received a suggestion to use vcl_hit and/or grace [2], but again -- no examples...</div><div><br></div><div>Could anyone provide some VCL pseudo-code that uses req.http.Cache-Control value to override TTL? max-age number parsing not necessary, I have figure that out.</div><div><br></div><div>Thanks,</div><div><br></div><div>Martynas</div><div><br></div><div>[1] <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#Cache_request_directives" target="_blank">https://developer.mozilla.<wbr>org/en-US/docs/Web/HTTP/<wbr>Headers/Cache-Control#Cache_<wbr>request_directives</a></div><div>[2] <a href="https://github.com/varnishcache/varnish-cache/issues/2014#issuecomment-319096566" target="_blank">https://github.com/<wbr>varnishcache/varnish-cache/<wbr>issues/2014#issuecomment-<wbr>319096566</a></div></div>
<br></blockquote></div></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">______________________________<wbr>_________________<br>
varnish-misc mailing list<br>
<a href="mailto:varnish-misc@varnish-cache.org" target="_blank">varnish-misc@varnish-cache.org</a><br>
<a href="https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc" rel="noreferrer" target="_blank">https://www.varnish-cache.org/<wbr>lists/mailman/listinfo/<wbr>varnish-misc</a><br></blockquote></div></div>
</blockquote></div>
</div></blockquote></div><br></div></div></div>