Varnish Cache is a high-performance HTTP accelerator that comes pre-installed on all Cloudways servers. It boosts website speed, reduces server load, and helps your applications handle high traffic with ease.
By serving cached content directly to visitors, Varnish ensures faster page loads, better scalability, and improved SEO performance.
In this guide, you’ll learn how to manage Varnish on Cloudways, configure exclusions, and adjust cache lifetime (TTL) for your applications.
Table of Contents:
What is Varnish?
Varnish Cache (often called “Varnish”) is an open-source HTTP web accelerator designed to cache and deliver static and dynamic content requests for dynamic websites.
It enables websites to load faster and helps reduce the server's load to endure a high volume of traffic.
Cloudways servers are shipped with Varnish pre-installed, so you and your website visitors enjoy faster load times and a premium user experience. The current version of Varnish is 6.0.x.
Benefits of Using Varnish
Varnish is very useful for those websites dealing with heavy traffic as such websites become slow over time, and the increased waiting time destroys the user experience.
Varnish is positioned in the middle of the browser (client) and the web server. When a client requests information from the server, Varnish saves a copy of all the requested information.
When the same resource is requested next time, the request is served by Varnish; thus, it boosts the website's speed by saving the time and resources it takes for a server to fulfill that request.
This boost helps to enhance the user experience of the website, helps in customer retention, and increases the chances of a high search position, as Google considers it a ranking factor.
In addition, Varnish learns about the resources that are being accessed frequently and gradually caches more data to serve the requests quickly.
As a result, your server does not encounter much load, and your websites continue to perform well by serving requests from the Varnish cache.
If your web server goes down or encounters any failure, Varnish will still deliver the cached pages of your website.
Varnish Compatibility with Web Applications
Varnish is fully compatible with the following web applications:
WordPress (including WooCommerce and WordPress Multisite)
Magento 2
Varnish is not compatible with the following web applications:
Laravel
Custom PHP
Default Configurations of Varnish
Cloudways Varnish Cache is an intelligent caching solution. By default, it has all the necessary configurations pre-applied, including which pages and cookies to cache and which to avoid for WordPress and Magento applications.
Such configurations ensure that only the pages and cookies you need are cached and served by Varnish.
These configurations are stored in the VCL file, which is the Varnish configuration file.
It is also highly customizable and flexible; therefore, you can exclude cookies and pages of your own choice from the Cloudways Platform.
It is important to understand that misconfigured cookies can sometimes disable caching or lead to cache misses.
Best practices include auditing unnecessary cookies that may interfere with Varnish's operations and testing plugins or headers that manipulate cache control.
Here is a list of all the essential items, cookies, and URLs excluded by default for WordPress and Magento applications.
Item Name | Description |
POST | All POST requests are excluded. |
HTTP Authorization | All password-protected websites are excluded. |
WordPress Specific Configurations
The following are the WordPress-specific configurations that Varnish excludes by default.
Item Name | Description |
WordPress Pages | All of the following WordPress pages are excluded.
|
WooCommerce Pages | All of the following WooCommerce specific pages are excluded.
|
Cookies | All of the following cookies are excluded.
|
RSS Feed | /feed are excluded. |
Easy Digital Downloads Pages and Cookies | All of the following pages and cookies are excluded.
|
Magento Specific Configurations
Magento 2 supports Varnish out-of-the-box; therefore, you don't require any third-party extensions. Cloudways also use the default VCL file with default settings, which Magento 2 offers.
How to Manage Varnish
By default, Varnish is enabled on all the Cloudways servers. When you enable Varnish on the server, the Varnish caching is enabled on all the applications hosted on that server.
When you disable Varnish on the server, the Varnish caching is disabled on all the applications hosted on that server.
There is also an option to enable Varnish on the server but disable the service on a particular application.
Enable/Disable Varnish on the Server
Here is how you can enable or disable Varnish on the server using the Cloudways Platform.
Log in to your Cloudways Platform using your credentials.
From the top menu bar, open Servers.
Next, choose your desired server.
Under Server Management, select Manage Services.
Next, click Enable in front of Varnish to activate the service. Likewise, you can disable Varnish by clicking Disable.
Disable Varnish on Specific Application
You can disable Varnish on a specific application but keep the Varnish active on the server.
Important:
Before proceeding further, ensure that the Varnish caching is enabled on the server.
From the top menu bar, open Servers.
Then, choose the server where your desired application is deployed.
Next, click www.
Choose your application.
Under Application Management, navigate to Application Settings.
Currently, the Varnish is enabled; therefore, click Disable Varnish.
Finally, click OK to save the changes. It will disable the Varnish for that specific application.
How to Exclude URLs and Cookies in Varnish
The default configurations of Varnish are sufficient, but you can also exclude several URLs and cookies in Varnish caching based on your requirements.
Troubleshooting Cookie-Related Caching Issues
To further enhance your caching configurations, many problems can be resolved by analyzing how cookies interact with Varnish caching. Misconfigured cookies or specific plugin behaviors can sometimes cause cache misses or other caching issues. Below are common scenarios and their remedies:
Cookies Causing a Cache MISS: If Varnish displays a "MISS" status, it might be due to problematic cookies. Troubleshooting involves analyzing cookies through the server logs or disabling/inspecting cookie-heavy plugins to ensure they are optimal for caching.
Plugins Disabling Caching with Cookies: Ensure that plugins such as WordPress Download Manager are not setting unnecessary cookies, or modify the plugin configuration as needed. Consult plugin support when required.
Note:
Before proceeding further, ensure that the Varnish caching is enabled on the server.
From the top menu bar, open Servers.
Then, choose the server where your desired application is deployed.
Next, click www.
Choose your application.
Under Application Management, navigate to Application Settings.
Switch to the Varnish Settings tab.
Click Add New Exclusion.
URL Exclusion
To exclude a URL, Select URL as Type.
Type the Value, such as the URL you want to exclude from Varnish caching.
Finally, click Save.
Important Notes:
Only relative URLs can be excluded from caching (e.g., /mypage.php) and not absolute URLs (http://mywebsite.com/mypage.php). Regular expressions can also be used.
Excluding URL (path) prevents Varnish from caching that specific resource. For instance, if you exclude a URL (/mypage.php), that file will not be cached by Varnish.
If you use an incomplete destination URL such as (/booking/) and if such path has more succeeding links such as booking/list or booking/items, all such items will not be cached by Varnish.
Cookies Exclusion
To exclude a cookie, Select Cookie as Type.
Type the Value such as the cookie name you want to exclude from Varnish caching.
Finally, click Save.
Important Note:
The cookie value will be the full cookie name. Regular expressions can also be used.
Excluding specific cookies would prevent the cookie strings caching and would allow them to work, bypassing caches. This is used when cookies create different sessions and calls are unique.
These cookie sessions are regularly updated and therefore are excluded from caching so that the sessions can be appropriately updated.
Once you have added all the rules, they will be visible in the same section. These rules can be easily edited or removed whenever needed.
You may need to use Varnish Purge if objects/URLs are previously being cached.
Troubleshooting HTTP Cookie Header Issues
By default, Varnish may not pass the HTTP Cookie header to PHP. This can cause issues in session handling or user-specific functionality. To resolve this:
Exclude specific URLs from Varnish caching where cookie headers must be passed.
Use appropriate rules in the Varnish Configuration Language (VCL) to ensure continuity between cookies and the application's backend processes.
Validate that the cookies bypass caching effectively after changes.
How to Change Varnish TTL
The Cloudways Platform offers a robust server-level caching solution known as Varnish. Our servers come with Varnish pre-installed, so you and your website visitors enjoy faster load times for the premium experience.
This section describes how to change the Varnish Time-to-Live (TTL) using the Cloudways Platform. Varnish is the secret ingredient behind our trailblazing stack to improve your website’s performance.
The time period for which Varnish caches content before being refreshed is called cache lifetime or Time-To-Live (TTL).
The default TTL value is set to 4 hours. Setting an optimum time helps to achieve significantly faster load times, which gives you an SEO boost and reduces the server's load.
Important:
Changing the TTL is a server-level configuration; thus, all websites (or applications) hosted on the same server, including staging sites, will be affected.
Here is how you can view and change the TTL value for Varnish in just a few clicks using the Cloudways Platform.
From the top menu bar, open Servers.
Next, choose your desired server.
Under Server Management, select Settings and Packages.
Next, switch to the Advanced tab.
Once you scroll down, you will see the Cache Lifetime option under Varnish.
Choose the value for the cache lifetime. For example, you can select 4 hours, 8 hours, 14 hours, or 24 hours.
Finally, click Save Changes.
Tip:
If you make frequent changes to your website, we encourage you to set a lower value for the TTL. On the other hand, increasing your TTL value is recommended if you do not make frequent content changes.
FAQs
How do cookies affect Varnish caching?
Cookies can significantly influence whether resources are cached or served dynamically. Specific cookies may disable caching or cause resources to bypass Varnish. Troubleshooting involves auditing plugin settings and header configurations.
Can I configure different cache exclusions for translated pages?
Yes, for translated pages (e.g., cart in English or 'warenkorb' in German), ensure their paths are explicitly added to the exclusion rules to maintain consistent behavior across pages.
What is Varnish?
Varnish Cache (often called “Varnish”) is an open-source HTTP web accelerator designed to cache and deliver static and dynamic content requests for dynamic websites. It enables websites to load faster and helps reduce the server's load to endure high traffic.
Does Varnish Cache Support HTTPS?
Applications, plugins, and extensions that support Varnish on Cloudways Platform will also work with HTTPS.
Does Varnish Cache 404 Pages?
Yes, Varnish Cache can indeed cache 404 pages with a default Time-To-Live (TTL) duration of 5 minutes.
That’s it! We hope this article was helpful.
Need Help?
If you need assistance, feel free to:
Visit the Cloudways Support Center
Chat with us: Need a Hand > Send us a Message
Or create a support ticket anytime.
We're here 24/7 to help you!











