Skip to content

Instantly share code, notes, and snippets.

@aondio
Created January 27, 2020 10:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aondio/07d88b56f1c5a5015f9ee7a02b3b4176 to your computer and use it in GitHub Desktop.
Save aondio/07d88b56f1c5a5015f9ee7a02b3b4176 to your computer and use it in GitHub Desktop.
varnishtest "Cut off ESI request should be retried"
server s1 {
rxreq
expect req.url == "/list"
txresp -body {<esi:include src="/fragment"/>}
rxreq
expect req.url == "/fragment"
txresp -status 503
# success
rxreq
expect req.url == "/fragment"
txresp -body "subrequest"
} -start
varnish v1 -vcl+backend {
sub vcl_recv {
# Track whether we are in ESI mode to know if we should retry 5xx errors
if (req.esi_level > 0) {
set req.http.doing-esi = "yes";
}
}
sub vcl_backend_response {
# retry backend errors during esi
if (bereq.http.doing-esi && beresp.status >= 500) {
set beresp.http.LOCATION = "HERE";
return(retry);
}
set beresp.do_esi = true;
}
}-start
varnish v1 -cli "param.set feature +esi_disable_xml_check"
client c1 {
txreq -url "/list"
rxresp
expect resp.status == 200
expect resp.body ~ "subrequest"
} -run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment