#TIL : Check vcl file syntax before restarting

Like NginX, Varnish has a syntax checker function that helps us test the syntactic correctness.

1
$ varnishd -C -f [vcl file path]

Varnish will compile the file and output the result to stdout. If something goes wrong, it will throw a message like

1
2
3
4
5
6
7
> Message from VCC-compiler:
> Expected an action, 'if', '{' or '}'
> ('input' Line 74 Pos 6)
> vcl_hash(req.http.Cookie);
> -----########------------------
>
> Running VCC-compiler failed, exit 1