Available in all subroutines.

Terminates a subroutine and sets the return state.


The return states available vary by subroutine. return can also be used to terminate custom subroutines and pass control back to the parent if used without a parameter. For example, the following code will set the header custom_header to "Hello big world":

sub my_custom_sub {
set req.http.custom_header += "big ";
set req.http.custom_header += "wide "; # Does not run
sub vcl_recv {
set req.http.custom_header = "Hello ";
call my_custom_sub;
set req.http.custom_header = "world."; # Runs because the `return` statement in my_custom_sub did not specify a return state

User contributed notes

We welcome comments that add use cases, ideas, tips, and caveats. All comments will be moderated before publication. To post support questions, visit our support center and we'll find you the help you need.