This plugin hasn’t been tested with the latest 3 major releases of WordPress. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

WordPress Varnish


This plugin purges your varnish cache when content is added or edited. This
includes when a new post is added, a post is updated or when a comment is
posted to your blog.

To keep widgets like “Recent posts”, “Recent comments” and such up to date,
you should consider using ESI and include them through a text widget for
arbitrary text or HTML.


  • Screenshot of the adminstration interface.


This section describes how to install the plugin and get it working.

  1. Install the plugin ‘WordPress Varnish’ through the ‘Plugins’ menu in
  2. Activate the plugin through the ‘Plugins’ menu in WordPress


Does this just work?


But how should my varnish configuration file look like?

I have provided a simple VCL that can be used as a reference.

Does it work for Multi-Site (or WPMU)?

Yes. Activating the plugin site-wide will provide the functionality to all
blogs. Configuration can be done on the blogs individually, or can be global.
If you want to configure Varnish servers globally, edit wp-config.php and
include these lines just before “That’s all, stop editing!” message:

global $varnish_servers;
$varnish_servers = array(‘’,’’);

The varnish servers array will configure multiple servers for sending the
purges. If VARNISH_SHOWCFG is defined, configuration will be shown to all
users who access the plugin configuration page (but they can’t edit it).

My Plugins are seeing the Varnish server’s IP rather than the websurfer IP

You could install Apache’s mod_rpaf module:

or, in wp-config.php, near the top, put the following code:

$temp_ip = explode(',', isset($_SERVER['HTTP_X_FORWARDED_FOR'])
(isset($_SERVER['HTTP_CLIENT_IP']) ?
$remote_addr = trim($temp_ip[0]);
$_SERVER['REMOTE_ADDR'] = preg_replace('/[^0-9.:]/', '', $remote_addr );

The code takes some of the common headers and replaces the REMOTE_ADDR
variable, allowing plugins that use the surfer’s IP address to see the
surfer’s IP rather than the server’s IP.

Contributors & Developers

“WordPress Varnish” is open source software. The following people have contributed to this plugin.


Translate “WordPress Varnish” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.



  • Added secret handling to WPVarnishPurgeObject, Thanks Kit Westneat
  • Change WPVarnishPurgePurgeCommonObjects to WPVarnishPurgeCommonObjects,
    Thanks kitwestneat
  • added @ to supress Undefined offset notice
  • minor doc changes


  • Added purge when post changes from future to publish, Thanks Marcin Pietrzak
  • Added purge when theme switched, Thanks dupuis
  • Fixed multisite domain mapping purge, Thanks jasonheffner
  • Updated Finnish Translation, Thanks timoleinio


  • Removed plugins_loaded action as it doesnt do what was expected re: Issue
    #12. Thank you Ben Favre, Pothi Kalimuthu and allinwonder


  • New .vcl to fix purge as per Issue #39, Thanks Ed Cooper


  • added rule to skip caching 404s in vcl
  • WordPress-Varnish UserAgent as per ticket #23
  • document use of mod_rpaf or code fix for remote IP, Ticket #36
  • clean data rather than reject to fix ticket #31
  • added plugins_loaded hook to fix ticket #12


  • Added internationalization code. Included pt_BR translation.
  • Support to Multi-Site and WPMU with global configuration.
  • Fix on URL purges for multiple domains and blogs on sub-directories.
  • Code clean up on some functions.
  • Added configuration for purging all blog, page and comments navigation.


  • Added multiple servers support and timeout configuration.


  • Initial release.