Varnish Cache
Varnish Cache is a high-performance HTTP accelerator and reverse proxy designed for content-heavy dynamic websites and APIs. It sits in front of web servers and caches HTTP responses to serve repeated requests without hitting the backend, dramatically reducing load and latency. Varnish is configured via VCL (Varnish Configuration Language), a domain-specific language for request/response policy, and managed through a CLI interface (varnishadm) and a set of command-line tools for logging, statistics, and monitoring.
APIs
Varnish Cache CLI API
The Varnish Cache CLI management interface provides programmatic control over a running Varnish instance. It is accessible via varnishadm or TCP socket and supports configuratio...
Varnish Logging Tools
Varnish ships with a suite of log-analysis tools that read from the Varnish Shared Log (VSL). Tools include varnishlog (raw log streaming), varnishncsa (NCSA/Apache log format),...
Varnish Modules (VMODs)
VMODs are extensions written for Varnish Cache that extend VCL capabilities. Bundled modules include blob (binary data handling), cookie (HTTP cookie parsing), directors (load b...
Features
Caches HTTP responses to reduce backend load and improve response times for repeated requests.
Domain-specific language for defining request/response handling policies with full programmability.
TCP-based management interface for runtime configuration, VCL deployment, and cache control.
Configurable health checks for backends with automatic failover to healthy backends.
Flexible cache invalidation via ban expressions matching any request/response attribute.
CLI commands support -j flag for structured JSON output, enabling programmatic management.
Loadable modules (VMODs) extend VCL with cookie parsing, load balancing, digest, auth, and more.
Native HTTP/2 support via the h2 VMOD for modern protocol acceleration.
High-speed shared memory logging with rich request/response attributes for analysis tools.
Worker thread pool for high-throughput concurrent request handling with configurable threading.
Use Cases
Cache REST API responses at the edge to reduce database and application server load.
Act as origin shield between CDN edge nodes and web/application servers.
Cache and serve static assets (images, JS, CSS) with long TTLs.
Use VCL to route traffic fractions to different backends for controlled experiments.
Absorb traffic spikes and rate-limit abusive clients via VCL policies.
Offload token validation and session checks to VCL logic at the cache layer.
Route requests to different backend pools based on URL patterns, headers, or cookies.
Integrations
Common deployment pairing with Nginx as backend web server behind Varnish.
Classic deployment with Apache as origin server behind Varnish Cache.
Deployable as a sidecar or DaemonSet in Kubernetes clusters for service-level caching.
Varnish statistics exportable via varnish_exporter for Prometheus scraping.
Community dashboards available for Varnish Cache statistics via Prometheus/Grafana.
Deep integration with Drupal Cache Tags for efficient purging of cached pages.
VCL configurations and plugins available for WordPress caching integration.
Fastly CDN is built on Varnish Cache; Fastly VCL is a fork of Varnish VCL.