PHPackages                             denismitr/etag - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. denismitr/etag

ActiveLibrary[HTTP &amp; Networking](/categories/http)

denismitr/etag
==============

Etag Middleware for Laravel

v2.1.0(6y ago)72661[1 issues](https://github.com/denismitr/etag/issues)MITPHPPHP ^7.2CI failing

Since Oct 21Pushed 6y ago1 watchersCompare

[ Source](https://github.com/denismitr/etag)[ Packagist](https://packagist.org/packages/denismitr/etag)[ RSS](/packages/denismitr-etag/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (4)Dependencies (4)Versions (7)Used By (0)

Laravel Etag Middleware for JSON APIs
=====================================

[](#laravel-etag-middleware-for-json-apis)

[![Build Status](https://camo.githubusercontent.com/ae1f4db016e6a9a01e905cdd2d7f675c41bb6539fcfed6550bae298bb8867703/68747470733a2f2f7472617669732d63692e6f72672f64656e69736d6974722f657461672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/denismitr/etag.svg?branch=master)

This a middleware specifically for the Laravel framework and **RESTful APIs** build with it. It hashaes the response content and adds it to ETag header of HTTP response. Then it listenes to **If-Match** and **If-None-Match** headers of the requests that expect to receive json in response in order to see if a new content needs to be delivered or just 304 Not Modified response is sufficient.

Author
------

[](#author)

**Denis Mitrofanov**

[TheCollection.ru](https://thecollection.ru)

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

[](#installation)

---

Use composer to install the package:

```
composer require denismitr/etag
```

Include in your `app/Http/Kernel.php` to the appropriate section (all requests if all your routes are API or named middleware + API middleware group to make it work for every api route or just named middleware):

Global middleware
-----------------

[](#global-middleware)

```
/**
 * The application's global HTTP middleware stack.
 *
 * These middleware are run during every request to your application.
 *
 * @var array
 */
protected $middleware = [
    ...
    \Denismitr\ETags\ETagMiddleware::class
];
```

Named middleware
----------------

[](#named-middleware)

```
/**
 * The application's route middleware.
 *
 * These middleware may be assigned to groups or used individually.
 *
 * @var array
 */
protected $routeMiddleware = [
    ...
    'etag' => \Denismitr\ETags\ETagMiddleware::class,
];

/**
 * The application's route middleware groups.
 *
 * @var array
 */
protected $middlewareGroups = [
    'web' => [
        ...
    ],

    'api' => [
        ...
        'etag'
    ],
];
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~96 days

Recently: every ~57 days

Total

6

Last Release

2279d ago

Major Versions

v0.3 → v1.02019-07-03

v1.0.x-dev → v2.0.02019-09-13

PHP version history (3 changes)v0.3PHP ^5.6 || ^7.0

v1.0PHP ^7.1.3

v2.0.0PHP ^7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d68ae5d5ca94f49a69f961a7825865d92247b09e276a25fcc6ad485d4c8c964?d=identicon)[denismitr](/maintainers/denismitr)

---

Top Contributors

[![denismitr](https://avatars.githubusercontent.com/u/16356446?v=4)](https://github.com/denismitr "denismitr (25 commits)")

---

Tags

httpresponserequestmiddlewarelaravelEtagETagsnot-modified

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/denismitr-etag/health.svg)

```
[![Health](https://phpackages.com/badges/denismitr-etag/health.svg)](https://phpackages.com/packages/denismitr-etag)
```

###  Alternatives

[psr/http-server-middleware

Common interface for HTTP server-side middleware

18091.2M1.5k](/packages/psr-http-server-middleware)[matthewbdaly/laravel-etag-middleware

A Laravel middleware for adding ETags to HTTP requests to improve response times

64326.0k2](/packages/matthewbdaly-laravel-etag-middleware)[idealo/php-middleware-stack

Implementation of HTTP Middleware PSR-15 specification

318.9k](/packages/idealo-php-middleware-stack)

PHPackages © 2026

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