This chapter introduces Varnish as an industry-leading reverse caching proxy and edge computing platform that accelerates websites, APIs, and video streaming by caching content in memory and reducing server load. It covers the Varnish Configuration Language (VCL) that enables advanced customization, distinguishes between the open-source Varnish Cache and commercial Varnish Enterprise versions, and explores multiple use cases including API acceleration, web acceleration, private CDN deployment, video streaming, and web application firewalling.
This chapter covers Varnish version 6, making the case for upgrading to this version by discussing its stability, performance improvements, and long-term support status, while also detailing key new features introduced across Varnish 6.x releases and comprehensive additions to Varnish Enterprise 6 such as cryptographic support, URL normalization, high availability, and numerous specialized modules for advanced caching and security use cases.
This chapter explores HTTP’s built-in caching semantics and emphasizes leveraging HTTP headers rather than custom VCL code to control Varnish caching behavior, covering topics including HTTP as a foundational protocol, caching mechanisms, conditional requests, range requests, compression, and content streaming. The core philosophy is that application backends can use standard HTTP response headers to express caching policies, allowing Varnish to automatically parse and act upon these directives, reducing VCL complexity while maintaining portability across different caching solutions.
This chapter introduces the Varnish Configuration Language (VCL), a compiled domain-specific programming language with C-like syntax that enables customization beyond standard HTTP caching mechanisms through hooks into Varnish’s finite state machine. It covers VCL fundamentals including the state machine architecture (request/response flows), syntax, objects and variables, along with practical guidance on making changes, validation, and testing to implement request/response manipulation, backend routing, and caching policies.
This chapter introduces Varnish Modules (VMODs), which are shared C libraries that extend VCL’s functionality beyond its domain-specific scope by exposing custom functions to VCL for tasks like string manipulation, type casting, and accessing third-party libraries. The chapter covers VMOD concepts including their purpose, API structure, installation, usage in VCL, and detailed documentation of both open-source VMODs shipped with Varnish Cache (blob, cookie, directors, proxy, std, unix) and additional VMODs in Varnish Enterprise.
This chapter covers cache invalidation strategies in Varnish, explaining why cache invalidation is critical for maintaining data consistency alongside high hit rates. It explores multiple mechanisms including purging (removing specific objects by URL), banning (expression-based invalidation of multiple objects), secondary keys using vmod_xkey and vmod_ykey for tag-based invalidation, and distributed invalidation across multiple Varnish servers using Varnish Broadcaster, while addressing the tradeoffs between flexibility and performance.
This chapter focuses on operational aspects of running Varnish at scale, shifting from development concerns to system administration and DevOps responsibilities. It covers critical topics including installation and configuration, security, high availability, load balancing, monitoring, storage, encryption, and deployments to ensure Varnish servers and origin infrastructure remain stable under millions of requests.
This chapter explores how Varnish can make intelligent caching decisions on the edge by handling stateful content, cookies, and authentication that would normally be uncacheable, using VCL combined with various VMODs (vmod_xbody, vmod_edgestash, vmod_http, vmod_kvstore, vmod_redis) to personalize cached responses and interact with external systems. Key topics include body access, HTTP calls, database access, geo features, synthetic responses, and implementing authentication gateways—demonstrating that Varnish goes far beyond simple caching to serve as a powerful edge computing platform.
This chapter explains how to build a private Content Delivery Network (CDN) using Varnish, covering CDN fundamentals, multi-tier architecture design, OTT video streaming protocols (HLS, MPEG-DASH, CMAF), and practical VCL examples for caching video content and managing cache across edge and storage tiers. It also discusses request routing strategies for geographically distributed PoPs and Varnish’s role in 5G multi-access edge computing (MEC) environments.
This closing chapter summarizes the key takeaways from the book, including developing hands-on Varnish knowledge, understanding HTTP’s importance for caching, appreciating Varnish’s performance capabilities, and recognizing the flexibility and power of the Varnish Configuration Language (VCL) for edge-computing. It also provides an overview of the broader Varnish ecosystem, including Varnish Enterprise commercial solutions, and discusses Varnish’s role as CDN technology for modern content delivery challenges and future growth prospects.
The Varnish Book by Thijs Feryn