Installation
Choose your preferred installation method:
Your First xvcl File
Create a simple hello.xvcl file:
#const SERVICE_NAME STRING = "My Awesome Service"
sub vcl_recv {
set req.http.X-Service = "{{SERVICE_NAME}}";
#for i in range(3)
if (req.http.X-Backend-ID == "{{i}}") {
set req.backend = backend{{i}};
}
#endfor
}
#for i in range(3)
backend backend{{i}} {
.host = "backend{{i}}.example.com";
.port = "80";
}
#endfor
Compile it to standard VCL:
xvcl hello.xvcl -o hello.vcl
Validate with Falco (if installed):
falco lint hello.vcl
Development Workflow
Write xvcl
Create your VCL configuration using xvcl's enhanced syntax with loops, functions, and macros.
Compile
Run xvcl to transpile your source to standard VCL. Use --debug for verbose output.
Validate
Use falco lint to check the generated VCL for errors and best practices.
Test
Run falco test on your VCL to verify behavior with unit tests.
Deploy
Upload the generated VCL to Fastly and activate your service.