per_call in vmod

Kristian Lyngstol kristian at
Mon Dec 5 11:12:50 CET 2011

On Fri, Dec 02, 2011 at 02:50:04PM -0500, AD wrote:
> hello,
>  How does per_call know what to cache on in the vmod?  Is it based on the
> parameters to the function or based on the request in the VCL?  I have run
> some tests previously where i make multiple http requests with different
> URLs and priv_call returns the same cached response.
>  Looking at this page
> it seems if
> i call a function in a vmod with priv_call with different parameters i
> should be able to cache them independently.  How is this supposed to work?

It is cached... per occurrence in VCL.

Meaning: For the same call, you will get the same private data
regardless of input. It's up to you whether the vmod needs to take the
parameters into account.

A good example of why this makes sense can be found in the header
vmod[1]. It has functions that take multiple arguments, but the first is
a regular expression. The regular expression is expected (required) to
be static. In other words: You write the regular expression by hand, but
the headers it are of course variable. The vmod can use per_call storage
to store the compiled regular expression, since the regex never changes.


sub vcl_recv {"blatti");"blatti");"blatti");;

will get exactly 4 priv_vcl structures, regardless of the value of

- Kristian

More information about the varnish-misc mailing list