PHPackages                             kleijnweb/rest-e-tag-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. kleijnweb/rest-e-tag-bundle

AbandonedArchivedSymfony-bundle

kleijnweb/rest-e-tag-bundle
===========================

Caching and Concurrency Control for REST APIs using E-Tag Headers

v1.0.0(10y ago)1130[1 issues](https://github.com/kleijnweb/rest-e-tag-bundle/issues)LGPL-3.0PHPPHP &gt;=5.4.0

Since Jan 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/kleijnweb/rest-e-tag-bundle)[ Packagist](https://packagist.org/packages/kleijnweb/rest-e-tag-bundle)[ RSS](/packages/kleijnweb-rest-e-tag-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (19)Versions (3)Used By (0)

KleijnWeb\\RestETagBundle
=========================

[](#kleijnwebrestetagbundle)

[![Build Status](https://camo.githubusercontent.com/70632f6e80f2d56c78328bb38f06251d88f157d08f3c7b0e7756c52a85459d3d/68747470733a2f2f7472617669732d63692e6f72672f6b6c65696a6e7765622f726573742d652d7461672d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kleijnweb/rest-e-tag-bundle)[![Coverage Status](https://camo.githubusercontent.com/f55021262e2bbe8cc02481895aa68bc2f10421fc543ec6949a59df1ba015be4a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6b6c65696a6e7765622f726573742d652d7461672d62756e646c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/kleijnweb/rest-e-tag-bundle?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/882d583242ce639a6392618eacb24dccb73415d9ab2837d101c5502db5d97eba/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b6c65696a6e7765622f726573742d652d7461672d62756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kleijnweb/rest-e-tag-bundle/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/1f08ab63fb58a84590bcc91acfbe145473a1d35764310f7015487295e02cce21/68747470733a2f2f706f7365722e707567782e6f72672f6b6c65696a6e7765622f726573742d652d7461672d62756e646c652f762f737461626c65)](https://packagist.org/packages/kleijnweb/rest-e-tag-bundle)

Small bundle that adds caching and Concurrency Control for REST APIs using E-Tag Headers.

Go to the [release page](https://github.com/kleijnweb/rest-e-tag-bundle/releases) to find details about the latest release.

For an example see [swagger-bundle-example](https://github.com/kleijnweb/swagger-bundle-example).

*NOTE:* Looking for PHP &lt;7.0 and Symfony &lt;2.8.7 support? Use a 01.x version.

Functional Details
------------------

[](#functional-details)

RestETagBundle uses REST semantics to form a cache invalidation and optimistic concurrency strategy.

- Versions the resources your URI paths represents and keeps this list in a server side cache.
- Increments the version of a path when one of the following methods is used: POST, PUT, PATCH, DELETE
- Increments the version of all parent and selected "lower" paths when that of a child is incremented
- Ensures the tag passed using If-Match matches the ETag in the cache, returns HTTP 412 in case of discrepancy.
- Returns HTTP 428 responses when concurrency control is enabled and the appropriate header is missing.

The bundle uses microtime based version IDs to prevent loss of the server side cache causing collisions and sub-second resource locking. Removes all non-printable and non-ascii chars from URLs before using them as cache keys.

The versioning scheme is pretty straightforward, examples:

- Modifying `/animals/rabbits/1`: Invalidates `/animals`, `/animals/rabbits`, `/animals/rabbits/1`, and (if it exists) `/animals/rabbits/1/relations/owners`
- GET on `/animals/rabbits/2`: This is not effected by the previous example. In addition, this will create a version if none exists yet (without invalidating anything)
- Modifying `/animals/rabbits`: Both `/animals` and `/animals/rabbits` get a new version. So will any existing versions matching the child invalidation constraint (see configuration), eg `/animals/rabbits/findByName`

The query part of the URL is treated as the last path segment:

- Modifying `/animals?type=rabbits`: Will be interpreted as modification of `/animals/?type=rabbits`. So `/animals` will be invalidated.
- GET on `/animals?type=rabbits`: Will be interpreted as GET `/animals/?type=rabbits`.
- Modifying `/animals/rabbits?id=1`: Will be interpreted as a modification of `/animals/rabbits/?id=1`. So the old versions of both `/animals` and `/animals/rabbits` are invalidated too.
- GET on `/animals?type=dogs`: Will be interpreted as GET `/animals/?type=dogs`. So a modification of `/animals?type=rabbits` will not affect it (but modification of `/animals` will invalidate it).

The default child invalidation constraint is a negated regular expression: `\/[0-9]+$`. This means a POST to `/animals/rabbits` will by default not invalidate `/animals/rabbits/1` or any paths below it, but will invalidate `/animals/rabbits/findByName`.

**NOTE:** When concurrency control is turned on, you cannot POST to without the correct E-Tag either.

**NOTE:** The store and retrieve calls are not yet fully optimized and get pretty chatty when using network based caches. You can probably expect best performance from APCu. It won't use that much memory.

Install And Configure
---------------------

[](#install-and-configure)

Install using composer (`composer require kleijnweb/rest-e-tag-bundle`). You want to check out the [release page](https://github.com/kleijnweb/rest-e-tag-bundle/releases) to ensure you are getting what you want and optionally verify your download.

Concurrency control is enabled by default. To disable:

```
rest_e_tags:
  concurrency_control: false
```

The bundle will work with any PSR-16 cache (networked caches are strongly discouraged). Use the 'cache' config option to reference the service to be used:

```
rest_e_tags:
  cache: my.cache.service
```

You can tweak the default child invalidation constraint (negated, see default above):

```
rest_e_tags:
  # Do not invalidate paths that look like they end in UUIDs (nor any paths below them)
  child_invalidation_constraint: '\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'
```

```
rest_e_tags:
  # Always invalidate, skip regex match
  child_invalidation_constraint: ''
```

License
-------

[](#license)

KleijnWeb\\RestETagBundle is made available under the terms of the [LGPL, version 3.0](https://spdx.org/licenses/LGPL-3.0.html#licenseText).

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~11 days

Total

3

Last Release

3738d ago

Major Versions

v0.9.0 → 1.x-dev2016-02-21

### Community

Maintainers

![](https://www.gravatar.com/avatar/cd6223a727c26ae6be208c1159924e9a2b43a9b11ae0da3afa1e641a49873fae?d=identicon)[kleijnweb](/maintainers/kleijnweb)

---

Top Contributors

[![johnknl](https://avatars.githubusercontent.com/u/8375560?v=4)](https://github.com/johnknl "johnknl (16 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kleijnweb-rest-e-tag-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/kleijnweb-rest-e-tag-bundle/health.svg)](https://phpackages.com/packages/kleijnweb-rest-e-tag-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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