Implementing esi onerror="continue" in vcl_backend_response using synthetic

Tom Anheyer Tom.Anheyer at Berlinonline.de
Wed Feb 17 17:23:10 CET 2016


Hi

we use something like:

sub vcl_deliver {
     # reformat errors in ESI requests
     if ( resp.status >= 300 && (req.esi_level > 0 || req.http.X-Esi ~ 
"\d") )  {
         return(synth(resp.status,resp.reason));
     }
}

sub vcl_synth {
...
     if ( req.esi_level > 0 || req.http.X-Esi ~ "\d" )  {
         synthetic("<!-- ESI error " + resp.status + " " + resp.reason + 
" URL: '//" + req.http.quotedUrl + "'  xid: " + req.xid + " -->");
     }
     else {
         ...
     }
     return(deliver);
}

tom

Am 16.02.2016 um 19:51 schrieb Andrew Bailey:
> 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
>
>
> _______________________________________________
> varnish-misc mailing list
> varnish-misc at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4266 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20160217/ce623ea1/attachment-0001.bin>


More information about the varnish-misc mailing list