Softpurge and nearly immediate refresh?
Guillaume Quintard
guillaume at varnish-software.com
Mon Apr 9 09:18:45 UTC 2018
Hi,
You can purge then set the method to GET then restart. Would that work for
you?
Other way is to use req.hash_always_miss that will only revalidate if we
are able to fetch a new object.
--
Guillaume Quintard
On Sat, Apr 7, 2018 at 12:10 PM, Danila Vershinin <ciapnz at gmail.com> wrote:
> Hi,
>
> What I work with:
>
> * Grace mode configured to be 60 seconds when backend is healthy
> * Using softpurge module to adjust TTL to 0 upon PURGE.
>
> The whole idea is increasing chances that visitors will get cached page
> after cache was PURGEd for a page.
>
> Standard piece:
>
> sub vcl_hit {
> if (obj.ttl >= 0s) {
> # normal hit
> return (deliver);
> }
>
> if (std.healthy(req.backend_hint)) {
> # Backend is healthy. Limit age to 60s.
> if (obj.ttl + 60s > 0s) {
> set req.http.grace = "normal(limited)";
> return (deliver);
> } else {
> return(fetch);
> }
> } else {
> # ...
> }
> }
>
> And use of softpurge:
>
> sub vcl_miss {
> if (req.method == "PURGE") {
> softpurge.softpurge();
> return (synth(200, "Successful softpurge"));
> }
> }
>
> sub vcl_hit {
> if (req.method == "PURGE") {
> softpurge.softpurge();
> return (synth(200, "Successful softpurge"));
> }
> }
>
>
>
> Current behaviour:
>
> * send PURGE for cached page
> * Visitor goes to the page within 60 seconds and sees a stale cached page
> (triggering background refresh)
> * Further visits to the page will show refreshed page
>
> What I’m looking for:
>
> Trigger the background refresh right after PURGE while still leveraging
> grace mode :) That is, serve stale cache for only as long as it takes to
> actually generate the new page, and not wait for 60 seconds:
>
> * upon PURGE: set TTL to 0 (softpurge) + trigger background page request
> (possible?)
> * serve stale cache only while the page is generated
>
> I could have adjusted the “healthy backend grace period” to lower than
> 60s, but I’m basically checking to see if it’s possible to refresh “nearly”
> immediately in this kind of setup.
>
> Hope I made any sense :)
>
> Best Regards,
> Danila
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20180409/bbedcd7c/attachment.html>
More information about the varnish-misc
mailing list