2017 © Pedro Peláez
 

sylex-provider varnishpurge

Varnish Purge Provider for Silex

image

mbence/varnishpurge

Varnish Purge Provider for Silex

  • Tuesday, October 21, 2014
  • by mbence
  • Repository
  • 2 Watchers
  • 0 Stars
  • 4,444 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 11 % Grown

The README.md

Varnish Purge Provider for Silex

Easy to use service to purge Varnish keys., (*1)

Description

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

https://www.varnish-cache.org/docs/3.0/tutorial/purging.html#http-purges, (*3)

Prerequisites

This Provider requires Sylex and Varnish-Cache ~v3.0. From the Varnish docs:, (*4)

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:, (*5)

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

Then download / update by running the command:, (*6)

``` bash $ php composer.phar update mbence/varnishpurge, (*7)


Composer will install the bundle to your project's `vendor/mbence/varnishpurge` directory. ### Step 2: Register the provider ``` php $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', (*8)

Usage

Call the service with a url, (*9)

php $app['varnish']->purge('/hello');, (*10)

The Versions

21/10 2014

dev-master

9999999-dev https://github.com/mbence/varnishpurge

Varnish Purge Provider for Silex

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

cache silex varnish purge invalidate