Softpurge and nearly immediate refresh?

Danila Vershinin ciapnz at gmail.com
Sat Apr 7 10:10:00 UTC 2018


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20180407/b0003f31/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20180407/b0003f31/attachment-0001.bin>


More information about the varnish-misc mailing list