What is Varnish Cache? How to configure it? Tutorial

What is Varnish Cache? How to configure it? Have you ever asked yourself, how can I improve the performance of my WooCommerce Website? Well, if the answer is yes, I'd like to introduce you to the Varnish Cache. But before that, let's talk about static content: images, scripts, pages, text, style sheets, etc.

When we talk about traditional hosting, the challenge is even bigger: there are hundreds of websites and thousands of static content required per second on the server. So they can't handle them and your site is broken.

What is Varnish Cache?

The Varnish Cache is a reverse proxy known as an HTTP accelerator. It is designed to deliver content as quickly as possible while having a load balancing function. It can also reduce the server load when storing objects and avoid database queries.

Being open source software, Varnish has featured many among its cache and load balancer servers. Version 1.0 was launched in 2006 and currently, Varnish Cache provides a highly customizable environment by applying VCL to the server configuration.

Another important feature of Varnish Cache is keeping the website online in case of an auxiliary problem. For those unaware, the backend may be another web server running Apache or Nginx, responsible for returning Varnish data to the buffer.

How does Varnish Cache work?

Unlike other proxy servers, which support a number of protocols such as FTP and SMTP, Varnish only focuses on HTTP. But its big advantage is the fact that it stores cached data in RAM, instead of using the server's hard disk as other buffer services do.

In the most common configuration, every HTTP request goes through Varnish first, responding if the object is still valid in the buffer. Whenever an object is not found or expires, it makes a request to the backend to return cached information later.


Typically, an HTTP request needs to use server resources to process code and database queries. With Varnish Cache, some steps can be avoided because the processing result is stored in the buffer, avoiding the need to reprocess each request.

Varnish can store static objects, that is, it stores processing results and other static files such as images, scripts, etc. This data is stored in memory, so the process of reading this information is faster and more efficient, despite increasing RAM consumption.

Is it worth using Varnish with WooCommerce?

Speed ​​matters when it comes to online commerce ventures. It is one of the biggest elements of user experience. Amazon calculates that they lost 1.6 billion dollars if the page load time increases by a second. That is not a big change!

Like many e-commerce platforms, WooCommerce also requires huge storage resources, especially when your store has a large inventory of products. Although it has an entire community of dedicated work to improve overall performance.

In addition, WooCommerce themes and settings are often complex with dynamic and static elements all jumbled up on a page, making advanced buffer systems difficult to set up. This is why having a storage mechanism like Varnish is so important for better performance.

How to configure Varnish on Cloud?

At Cloud, we are always looking for ways to improve the performance of our managed WooCommerce hosting service and work on the suggestions provided to customers, developers, small and medium-sized businesses, agents. and the WordPress community in general.

Keeping up with our long-term practice, we have found a suitable solution to exploit and enhance WooCommerce and Varnish compatibility. As an intuitive platform, you can see how to launch WooCommerce and configure Varnish settings (in another section) along with some common rules.


Varnish performance benchmarks

Below is a load test result comparing performance of WooCommerce without Varnish and WooCommerce with Varnish.

Without Varnish, the average response time is 1779 ms.


With Varnish, the response time was stable at 6 ms.


As seen in the chart below, the response rate is affected when more and more users visiting WooCommerce website runs without Varnish.


If Varnish is properly configured with WooCommerce, the load test results show that the response rate becomes stable when a lot of visitors come to the site. The initial response is high-speed, but when HTTP requests are cached, new users experience a smooth response time.


Tests clearly show that the server's average response becomes stable even when 500 users are visiting your site, while the server without Varnish struggles to respond to every new visitor coming. do web slowed. It is harmful to your business.

One of our first users, WooCommerce has been available as a beta application since the beginning of this year.

Common rules for WooCommerce

Pages to exclude

The following WooCommerce sites should be excluded from Varnish.

  1. cart
  2. Payment procedures
  3. Add to cart

Inside Cloud Platform, go to Application Management → Application Settings → Blur settings.


Click the ‘Add new rule’ button and select ‘Url’ from the drop down list.


Specify the URL (for example, the shopping cart) within the ‘Value’ field and press ‘Save’.

Varnishing rules for the cart

Cookies to exclude

Similarly, cookies can also be excluded by using the same settings.

  1. wooc Commerce_items_in_cart
  2. wp_wooc Commerce_session_
  3. wooc Commerce_cart_hash

To exclude cookies; select ‘Cookies’ from the drop down menu and locate the cookie inside the Value field.



seo marketing wordpress seo seo hosting seo and marketing word press seo wordpress and seo wordpress marketing hosting seo seo press pro market seo seo & marketing seo e marketing e marketing seo seo pro wordpress marketing & seo seo di wordpress wordpress seo host hosting and seo wordpress hosting seo wordpress seo wordpress wordpress for marketing seo press wordpress marketing for seo