Varnish is the cutting edge in reverse proxy for speeding up web services and reducing load on your web application server.  It has a pretty neat CLI for managing a running Varnish instance, but being an interactive telnet interface, it is not so easy to script for…

Some examples why you might want to interface to the Varnish CLI with a script:

  • Automatic reload of configuration file when it changes
  • Purge the cache for a specific website when changes are made (new blog entry, new CSS, …)

And so I wrote up a Perl interface to the Varnish CLI (git repo here).  The module is Moosey, and requires Net::Telnet and Digest::SHA to run.

It’s pretty easy to use – here’s a snippet with which you can purge your cache:

use Varnish::CLI;
my $v = Varnish::CLI->new();
$v->send( "url.purge .*" );

Have fun, and keep your web services zipping with Varnish! 🙂

You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.