restarting for bad synchronous responses - Re: PATCH: stale-while-revalidate support

Nils Goroll slink at
Mon Aug 11 23:33:25 CEST 2014


I have started writing up a suggestion following an irc discussion about
Federicos patch. I wanted to suggest to also add stale-if-error (s-i-e) support
but really I don't see a way at the moment to achieve this without added
functionality in vcl - am I missing something?

For s-i-e, I think we need to handle the case of a synchronous backend fetch (ie
one with one or more frontend requests waiting for the result) resulting in "an
error". We'd have to restart the frontend request once and check for a stale
object as in

	vcl_hit {
		// got here not because of grace but because of
		// keep or some other parameter
		if (req.restarts == 1) {
			return (deliver);

The options I see at the moment to achieve this would all require additions to VCL:

- something along the lines of a beresp.fetched ("this object originated
  from a fetch initiated by this req"):

  vcl_deliver {
	if (beresp.fetched && req.restarts == 0 && beresp.status >= 500) {
		return (restart);


- some way to determine in v_b_e and v_b_r if the bereq is synchronous
  and restart the req.

 sub vcl_backend_(response|error) {
	if (bereq.synchronous.req && beresp.status > 500) {

Thanks, Nils

More information about the varnish-dev mailing list