1
votes

Could you help me in confirming the default behavior of vcl_recv in Varnish ?

vcl_recv definition that comes in default.vcl file is commented out in the application setup.

We have provided our custom version of vcl_recv in a vcl file without specifying a return(lookup) or lookup statement. However caching seems to be proper when trying to access an images or static content. Does varnish internally implement some sort of logic to cache on top of what is defined in default.vcl's vcl_recv and user defined vcl_recv ?

Thanks

1

1 Answers

0
votes

Explanation

When you define a custom VCL (vcl_recv in this case) Varnish automagically appends the default VCL to yours.

Keep in mind that if you do something like return(lookup)/pass/etc in your VCL, varnish default VCL won't be executed after that line is executed.

From Varnish docs:

It is executed right after any user-specified VCL, and is always present. You can not remove it.

And:

Consider either replicating all the logic in your own VCL, or letting Varnish fall through to the default VCL.

Example

sub vcl_recv {
      if (req.http.host ~ "dev") {
             return(pass);
      }
}

This won't save in cache any request that has a "dev" in its host. But it will still save in cache anything else.

Extra:

Great tool to be sure if varnish is working: Here