call

callIDsubroutine_name;

Available inall subroutines.

Invokes a user-defined subroutine that does not have a return type.

HINT: Custom subroutines that return a value are supported but are not invoked using the call statement. Learn more.

You can define custom subroutines in the same way as built-in subroutines, and invoke them using call statement. Control passes to the custom subroutine and returns to the calling point when the subroutine ends, unless the subroutine includes a statement that would terminate the current lifecycle state.

sub compression_check {
if (req.http.Accept-Encoding ~ "gzip|br") {
set req.http.Compression-Accepted-By-Client = "yes";
}
}
sub vcl_recv {
call compression_check;
}

Custom subroutines defined and invoked in this way do not accept parameters and do not return a value, but may apply side effects to a request, such as modifying request state. All custom subroutines have access to the same request-level state that the calling subroutine does (so, for example, a custom subroutine called from vcl_fetch would be able to set beresp.ttl), but do not have access to local variables defined in the parent subroutine. Likewise, local variables defined in a custom subroutine are not accessible outside it.

Custom subroutines may include the terminating statements restart, return or error. In the case of return without an argument, control passes back to the line after the call statement (which is also the default behavior if the custom subroutine does not contain any terminating statements). However, in the case of a return with an argument, a restart or an error from inside a custom subroutine, the parent subroutine will be terminated as well, with the specified exit state.

A custom subroutine may call another custom subroutine. It is not possible to call a built-in VCL subroutine.