Varnish 4 is quite an extensive update over Varnish 3, with some very big improvements to central parts of varnish.
Client/backend split
--------------------
In the past, Varnish has fetched the content from the backend in the same
thread as the client request. The client and backend code has now been split,
allowing for some much requested improvements.
This split allows varnish to refresh content in the background while serving
stale content quickly to the client.
This split has also necessitated a change of the VCL-functions, in particular functionality has moved from the old vcl_fetch method to the two new methods vcl_backend_fetch and vcl_backend_response.
Much of the VCL syntax has changed in Varnish 4. We've tried to compile a list of changes needed to upgrade here.
Version statement
~~~~~~~~~~~~~~~~~
To make sure that people have upgraded their VCL to the current version, varnish now requires the first line of VCL to indicate the VCL version number::
vcl 4.0;
vcl_fetch is now vcl_backend_response
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Directors have been moved to the vmod_directors
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Use the hash director as a client director
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Since the client director was already a special case of the hash director, it has been removed, and you should use the hash director directly::
sub vcl_init {
new h = directors.hash();
h.add_backend(b1, 1);
h.add_backend(b2, 1);
}
sub vcl_recv {
set req.backend = h.backend(client.ip);
}
error() is now a return value
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You must now explicitly return an error::
return(error(999, "Response));
hit_for_pass objects are created using beresp.uncacheable