Overview of Varnish Configuration Language (VCL)
masterVarnish uses a domain-specific language called VCL (Varnish Configuration Language) to handle HTTP traffic. Instead of simple configuration switches, VCL allows you to influence how every inbound request is handled by altering requests and responses, directing traffic to specific backends, or taking arbitrary actions based on request/response properties.
Key characteristics:
- Performance: Varnish translates VCL into binary code for execution, resulting in negligible performance impact.
- Structure: VCL files are organized into subroutines that execute at different stages of the request lifecycle (e.g., when a request arrives or when files are fetched from a backend).
- Default Behavior: If a subroutine does not explicitly call an action, Varnish executes built-in VCL code. This default code is available as comments in the
builtin.vclfile provided with Varnish Cache.