Skip to content

mbence/varnishpurge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Varnish Purge Provider for Silex

Easy to use service to purge Varnish keys.

Description

This provider will create a PURGE request for the predefined Varnish servers, thus invalidating the given url.

https://www.varnish-cache.org/docs/3.0/tutorial/purging.html#http-purges

Prerequisites

This Provider requires Sylex and Varnish-Cache ~v3.0. From the Varnish docs:

acl purge {
        "localhost";
        "192.168.55.0"/24;
}

sub vcl_recv {
        # allow PURGE from localhost and 192.168.55...

        if (req.request == "PURGE") {
                if (!client.ip ~ purge) {
                        error 405 "Not allowed.";
                }
                return (lookup);
        }
}

sub vcl_hit {
        if (req.request == "PURGE") {
                purge;
                error 200 "Purged.";
        }
}

sub vcl_miss {
        if (req.request == "PURGE") {
                purge;
                error 200 "Purged.";
        }
}

Installation

Step 1: Download the bundle using composer

Add the following in your composer.json:

{
    "require": {
        "mbence/varnishpurge": "dev-master"
    }
}

Then download / update by running the command:

$ php composer.phar update mbence/varnishpurge

Composer will install the bundle to your project's vendor/mbence/varnishpurge directory.

Step 2: Register the provider

$app->register(new MBence\VarnishPurge\VarnishPurgeProvider(), array(
    'varnish.options' => array(
        'servers'   => array('127.0.0.1:8080'),
        'purge'     => 'On'
    ),
));

You can turn the purge off with 'purge' => 'Off'

Usage

Call the service with a url

$app['varnish']->purge('/hello');

About

Varnish Purge Provider for Silex

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages