Search

What is Varnish?

What is Varnish?

Originally, Varnish was a reverse caching proxy: a proxy server that speaks HTTP that you put in front of your web servers. Varnish heavily reduces the load and the latency of your web servers.

It does this by serving client requests with content that is cached in memory, eliminating the need to send each client request to the web servers.

However, when the content for a request is not available in cache, Varnish will connect to web servers to retrieve the requested content, and will attempt to store the response in cache for future requests.

By adding this new layer of caching, we divide the platform into two distinct tiers in terms of content delivery:

  • The origin: represents your original web servers that are inherently prone to high load and latency, and that need to be protected in order to guarantee stability.
  • The edge: the outer tier of your platform. It is secure, stable, fast and scalable. This is where users interact with your content and where Varnish really shines.

Basic Varnish Diagram

Because Varnish speaks HTTP and sits in front of the web servers, it seemingly assumes the role of the web server. The HTTP client that connects to the platform has no idea that Varnish is actually a proxy. In a lot of cases, the same applies to the origin servers: most of the time, they have no clue that Varnish is a proxy and not a regular HTTP client.

Varnish is available in two forms:

Varnish Enterprise is maintained by Varnish Software, whereas Varnish Cache is maintained by both Varnish Software and the open source community.

Varnish Software employs most of the engineers working on Varnish Cache. In addition Varnish Software maintains the long-term support (LTS) version of Varnish Cache.

More information about the differences between the two versions can be found in a dedicated section in this chapter.

In its default configuration, Varnish will respect Cache-Control headers from the web server, and cache objects for the amount of time the web server indicates, or not at all. There are built-in mechanisms to do this in a safe way, so that private information is not stored in the cache. This means that a web developer can gain a lot from Varnish with just some basic configuration.

However, much of the power of Varnish is that its behavior can be configured and changed in many ways. There are many parameters that can be tuned. Request handling and caching behavior can be altered, or completely redefined, using the Varnish Configuration Language (VCL).


®Varnish Software, Wallingatan 12, 111 60 Stockholm, Organization nr. 556805-6203