PHPackages                             lbarulski/cache-tags-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. lbarulski/cache-tags-bundle

ActiveLibrary[Caching](/categories/caching)

lbarulski/cache-tags-bundle
===========================

Bundle for custom varnish tags

v1.2.3(3y ago)3251.0k↓39.7%4MITPHPPHP &gt;=5.4

Since Jun 17Pushed 1y ago4 watchersCompare

[ Source](https://github.com/lbarulski/CacheTagsBundle)[ Packagist](https://packagist.org/packages/lbarulski/cache-tags-bundle)[ RSS](/packages/lbarulski-cache-tags-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (6)Versions (10)Used By (0)

CacheTagsBundle
===============

[](#cachetagsbundle)

CacheTagsBundle is simple Cache Tag and Cache Invalidation for Varnish Cache

[![Total Downloads](https://camo.githubusercontent.com/aec3243dc3da5f80abbecf0a3e7ee78be69c227d562b1c82c2670cfb933b7c5a/68747470733a2f2f706f7365722e707567782e6f72672f6c626172756c736b692f63616368652d746167732d62756e646c652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/lbarulski/cache-tags-bundle)

Varnish VCL
===========

[](#varnish-vcl)

```
sub vcl_recv {
    if (req.request == "BAN") {
        if (req.http.X-CACHE-TAG) {
            ban("obj.http.X-CACHE-TAGS ~ " + req.http.X-CACHE-TAG);
        } else {
            error 400 "Tag not given";
        }

        error 200 "Banned";
    }
}

```

Installation
------------

[](#installation)

The CacheTagsBundle library is available on [Packagist](https://packagist.org/packages/lbarulski/cache-tags-bundle). You can install it using \[Composer\] ():

#### Method 1

[](#method-1)

Simply run assuming you have installed composer.phar or composer binary:

```
$ composer require lbarulski/cache-tags-bundle
```

#### Method 2

[](#method-2)

1. Add the following lines in your composer.json:

```
{
  "require": {
    "lbarulski/cache-tags-bundle": "2.0.x-dev"
  }
}
```

2. Run the composer to download the bundle

```
$ composer require 'lbarulski/cache-tags-bundle:2.0.x-dev'
```

### Add this bundle to your application's kernel

[](#add-this-bundle-to-your-applications-kernel)

```
// app/ApplicationKernel.php
public function registerBundles()
{
    return array(
        // ...
        new lbarulski\CacheTagsBundle\CacheTagsBundle(),
        // ...
    );
}
```

### Configuration config.yml example

[](#configuration-configyml-example)

```
# app/config/config.yml
cache_tags:
    response:
        tag: X-CACHE-TAGS
    proxies:
        varnish:
            - host: host.tld
              port: 80
              path: /
              timeout: 1
              header: X-CACHE-TAG
              host_header: my.site.com # deprecated, add `Host` header instead
              headers:
                - name: Host
                  value: my.site.com
            # For SSL
            - host: ssl://host.tld
              port: 443
              path: /
              timeout: 1
              header: X-CACHE-TAG
              host_header: my.site.com # deprecated, add `Host` header instead
              headers:
                - name: Host
                  value: my.site.com
              ssl_verify_peer: true

```

`host_header` Allows to spoof request host header; Optional, defaults to `host` value

### Usage examples:

[](#usage-examples)

#### Controller: plain cache tag

[](#controller-plain-cache-tag)

```
// Acme\MainBundle\Controller\ArticleController.php

use lbarulski\CacheTagsBundle\Annotation\CacheTag\Plain;
...

/**
 * @CacheTag\Plain("article_name")
 **/
public function articleAction(Request $request)
{
    ...

    $response = new Response('...');
    $response->setPublic();
    $response->setTtl(3600);

    return $response;
}
```

#### Controller: request attribute tag

[](#controller-request-attribute-tag)

```
// Acme\MainBundle\Entity\Article.php

use lbarulski\CacheTagsBundle\Tag\CacheTagInterface;

class Article implements CacheTagInterface
{
    ...

    public function getCacheTag()
	{
		return 'article_'.$this->getId();
	}
}
```

```
// Acme\MainBundle\Controller\ArticleController.php

use lbarulski\CacheTagsBundle\Annotation\CacheTag\RequestAttribute;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
...

/**
 * @ParamConverter("article")
 * @CacheTag\RequestAttribute("article")
 **/
public function articleAction(Article $article)
{
    ...

    $response = new Response('...');
    $response->setPublic();
    $response->setTtl(3600);

    return $response;
}
```

#### View Template: use esi controller

[](#view-template-use-esi-controller)

```
{{ render_esi(controller('MainBundle:Article:article', { article: article.id })}}
```

### Invalidate

[](#invalidate)

#### Command invalidate TAG:

[](#command-invalidate-tag)

```
$ ./app/console cache_tags:invalidate tag
```

#### Invalidate TAG:

[](#invalidate-tag)

```
// Acme\MainBundle\Controller\ArticleController.php

use lbarulski\CacheTagsBundle\Tag\Plain;
...

public function updateArticleAction(Article $article)
{
    ...
    $tag = 'article_name';
    $this->get('cache_tags.invalidator')->invalidate(new Plain($tag));
    ...
}
```

Presentation
------------

[](#presentation)

License
-------

[](#license)

This library is released under the MIT license. See the included [LICENSE](LICENSE) file for more information.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 64.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~333 days

Recently: every ~609 days

Total

9

Last Release

1369d ago

PHP version history (2 changes)v1.1.0PHP &gt;=5.3.3

v1.2.2PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/69f6df2cde2ee864e1ea5ec591e9a586ed97994c87996944194ef03e2ad63086?d=identicon)[prgTW](/maintainers/prgTW)

![](https://www.gravatar.com/avatar/10ae2527ad43745ea12faa6b628461b5eadd38cc4135d7eb534f29a374f9759e?d=identicon)[lukasz.barulski](/maintainers/lukasz.barulski)

---

Top Contributors

[![prgTW](https://avatars.githubusercontent.com/u/203249?v=4)](https://github.com/prgTW "prgTW (33 commits)")[![SongoQ](https://avatars.githubusercontent.com/u/521940?v=4)](https://github.com/SongoQ "SongoQ (12 commits)")[![lbarulski](https://avatars.githubusercontent.com/u/2803144?v=4)](https://github.com/lbarulski "lbarulski (5 commits)")[![kolah](https://avatars.githubusercontent.com/u/448553?v=4)](https://github.com/kolah "kolah (1 commits)")

### Embed Badge

![Health badge](/badges/lbarulski-cache-tags-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/lbarulski-cache-tags-bundle/health.svg)](https://phpackages.com/packages/lbarulski-cache-tags-bundle)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
