Caching on WordPress using Varnish

Estimated reading: 2 minutes

Caching your WordPress using ClusterCS
Whether you want more speed, a better experience for your visitors, for SEO, or any personal reason, chances are you want a caching layer on your website.
Caching in ClusterCS is achieved by spending only a few minutes in the Control Panel.

In order to get started, be sure that you have added Varnish as a service to your server:

Servers > Manage > Webserver > Manage > Add Varnish > Save

Also be sure that you have Smart Traffic Manager/haproxy checked like in the example below:

Start by going in the Speed tab of your domain.

Now you should scroll down to ADD NEW RULE

and set the following conditions, which I will explain lower:

path begins_with / – this is the base path on which the cache layer should be applied. if your WordPress installation is located in a subfolder please adjust accordingly, ex: “path begins_with /blog”

path not_ends_with .php – calls to php files are most likely custom data that should not be cached

cookie – not_contains – wordpress_logged_in – WordPress maintains a cookie which is an indicator of this state – wordpress_logged_in – if it caches it, then some private user data may be shown publicly

method – get – other types usually have important actions being carried and shouldn’t be lost

You will also need a Clear Cache rule that can be set like in the example below:

Clear Cache Rule:

IP from Your_IP – make this specification in order to have the clear cache link accessible only from your location of choice, for security reasons

Don’t forget to set the last option with “cache_with Webserver/Varnish

Once everything is set up, you need to give your domain some time (Might take about 30 minutes to websites with high traffic) to populate the cache. During that time, you may experience some higher resource load, which is totally normal.

For more in-depth details about the Speed Engine, please visit our KB Article

Now you can take full advantage of your cache and serve more users, faster!

Share this Doc