-
Notifications
You must be signed in to change notification settings - Fork 65
How to configure Varnish
Varnish is a powerful component of the modern WordPress server stack. It serves as the HTTP caching layer and allows your WordPress installation to handle a lot of traffic. This guide will show you how to configure Varnish beyond the default DebOps configuration.
This guide assumes that you're familiar with how to customize your server. If you don't know how or aren't sure, take a moment to go over this guide first.
By default, DebOps only configures Varnish to work with the default WordPress installation. This means that Varnish might have issues with certain plugins. Below are plugins that need some extra Varnish configuration to work without issues.
Varnish HTTP purge is a plugin created by Dreamhost for its infrastructure. That means that there's no guarantee that it'll work with DebOps. The good news is that it pretty much works out of the box! The configuration below is only necessary if you want the "Purge Varnish" button to work.
wordpress__varnish__add_ban_lurker_headers: True
wordpress__varnish__purge_conditions:
'req.http.X-Purge-Method ~ "(?i)regex"': |
ban("obj.http.X-Url ~ " + req.url + " && obj.http.X-Host == " + req.http.host);
return (synth(200, "Purged"));
As an eCommerce platform, WooCommerce requires that a lot of its pages stay uncached. This is because a lot of visitors won't log in, but will still need pages rendered by WordPress. The configuration below implements the recommendations from the WooCommerce documentation.
wordpress__varnish__vcl_recv_conditions:
'req.url ~ "^/(cart|my-account|checkout|addons)" || req.url ~ "\?add-to-cart="': 'return (pass);'
You don't need to create a new server to make changes to Varnish. DebOps can update an existing server with the configuration changes that you've made. You just need to run the WordPress DebOps playbook with the `depend::varnish`` tag.
$ debops wordpress --tags depend::varnish
Getting Started
Adjusting performance
Cookbook
- How to configure a server for a Bedrock project
- How to configure multiple WordPress sites on a single server
- How to configure Varnish
- How to create a multisite network
- How to customize your server
- How to manage additional users
- How to manage WordPress plugins
- How to secure your WordPress site
Troubleshooting
Appendix