Implementing esi onerror="continue" in vcl_backend_response using synthetic

Andrew Bailey andrew.bailey at apps4u.co
Tue Feb 16 19:51:43 CET 2016


Hi,

I am using varnish 4.1 and would like to implement something similar to

<esi:include src="apage-head.html" onerror="continue"/>

which does not appear to be supported yet.

I have:

sub vcl_backend_response {
        if (bereq.url ~ "-head.html$"  && beresp.status==404)
        #if (req.esi_level>0  && beresp.status==404) //Commented as
Variable not available
        {
                #set beresp.status = 700; //this is for attempts to forward
to vcl_synth
                set beresp.status = 200;
                set beresp.http.Content-Type = "text/html; charset=utf-8";
                set beresp.reason="esi include failed with a 404";
                #synthetic("<!-- esi include failed with a 404-->"); # not
a valid action from method
                #call vcl_synth; # still cant use synthetic
                #call vcl_backend_error; #ditto
                return (deliver);
        }

I think it should be valid to call synthetic here, any chance of this for a
future version?

Also I tried to see if it is in the middle of esi processing using
req.esi_level however that is not available in this method.

 I have tried several workarounds
return(synth ...)
call vcl_synth
but no luck.

Can anyone provide a working solution.


thanks in advance

Andrew Bailey
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20160216/8238ea84/attachment.html>


More information about the varnish-misc mailing list