PHPackages                             krenor/http2-pusher - 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. krenor/http2-pusher

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

krenor/http2-pusher
===================

Cache aware HTTP/2 pushing for Laravel.

1.0.0(8y ago)16321[1 PRs](https://github.com/krenor/http2-pusher/pulls)MITPHPPHP &gt;=7.0.0

Since Feb 13Pushed 3y ago2 watchersCompare

[ Source](https://github.com/krenor/http2-pusher)[ Packagist](https://packagist.org/packages/krenor/http2-pusher)[ RSS](/packages/krenor-http2-pusher/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (9)Versions (4)Used By (0)

Cache aware HTTP/2 pushing for Laravel
--------------------------------------

[](#cache-aware-http2-pushing-for-laravel)

[![Packagist](https://camo.githubusercontent.com/67f2f224f6b8fa86c204bbd101ce5dc1f812b3a4d0d3f9d6c9fcc9dbe4e81477/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b72656e6f722f68747470322d7075736865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/krenor/http2-pusher)[![Travis](https://camo.githubusercontent.com/e34b40f95abae5703cb749b07e9d3a478fed61f4ec88e971c0e01a100037a7a6/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6b72656e6f722f68747470322d7075736865722e7376673f7374796c653d666c61742d737175617265)](http://travis-ci.org/krenor/http2-pusher)[![Quality](https://camo.githubusercontent.com/7848a8bae7d0d406c72977639bc8dc4b8922efe9e5210c52d75fc720636e59d3/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6b72656e6f722f68747470322d7075736865722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/krenor/http2-pusher)[![Coverage](https://camo.githubusercontent.com/83cddde72c32a41e03cddb4dfa21f566d6b24134e7e85ec22f8ed82c47d20723/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6b72656e6f722f68747470322d7075736865722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/krenor/http2-pusher)[![Dependencies](https://camo.githubusercontent.com/f2375440e3879f25e429367ef2e585d0cd578c3c2cbbbf652153ec5542900b18/68747470733a2f2f696d672e736869656c64732e696f2f67656d6e617369756d2f6b72656e6f722f68747470322d7075736865722e7376673f7374796c653d666c61742d737175617265)](https://gemnasium.com/krenor/http2-pusher)[![Downloads](https://camo.githubusercontent.com/c33cf4d09b462239d3cd3dc5dfd21e2cb735921c74c9eb6862807bdbadfdea43/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b72656e6f722f68747470322d7075736865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/krenor/http2-pusher)[![License](https://camo.githubusercontent.com/820e7dbac2b8a5f1d084af8cca72686ac5ba9c6ba49a509db9caef30123e72fe/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b72656e6f722f68747470322d7075736865722e7376673f7374796c653d666c61742d737175617265)](https://github.com/krenor/http2-pusher/blob/master/LICENSE.md)

HTTP/2 is a great advancement for the HTTP protocol, allowing multiple assets to be streamed over a single TCP connection. This reduces the need for “optimisation practices” such as domain sharding, image sprites, etc. There is one really cool feature of HTTP/2 however which can greatly speed up the render time of your website, and that is server push. Server push allows you to send your assets along with the HTML payload before the browser even knows it needs those assets. [(Source)](https://iwader.co.uk/post/using-http2-server-push)

Without *cache digests* there is no clear-cut performance win for HTTP/2 Server Push over HTTP/1 Asset Bundling. *Cache digest* is a [specification](https://github.com/httpwg/http-extensions#cache-digest) currently under discussion at the IETF HTTP Working Group. [(Source)](https://calendar.perfplanet.com/2016/cache-digests-http2-server-push)

This package aims to create a cache aware mechanism for HTTP/2 Server Push until *cache digest* is available. It helps to push exactly what is needed; no more, to waste bandwith and no less, which would result in round trip latency.

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

[](#installation)

You can install the package via composer:

```
composer require krenor/http2-pusher
```

Laravel 5.5 uses [Package Auto-Discovery](https://laravel-news.com/package-auto-discovery), so it doesn't require you to manually add the ServiceProvider to your providers array configuration.

Configuration
-------------

[](#configuration)

You can configure three things

- `cookie`
    - `name` *(default: `h2_cache-digest`)*
    - `duration` Requires a valid `strtotime` value *(default: `60 days`)*
- `global_pushes` Assets you want to be pushed for **every** page load

Usage
-----

[](#usage)

- When you route a request through the `ServerPush` middleware, the response is scanned (unless its a `RedirectResponse` or either a `json` or `ajax` request) for any assets that can be pushed.
- Alternatively you can use the `pushes()` method on the `Response` class, which extends the default `\Illuminate\Http\Response`, provided by this package's ServiceProvider.
- Using the `response()` helper works as fine, however hinting of the `pushes()` method will **not** be available.

Both methods will add a `Link` header and a Cookie to the response with all the assets found and the configured via `global_pushes`. On subsequent requests the cookie will be scanned with its already pushed resources. If any new resources are available or if the pushed resources have changed the `Link` header and the Cookie will be extended to include these.

**Note**: Only [these extensions](https://github.com/krenor/http2-pusher/blob/master/src/Builder.php#L30) are currently supported.

This isn't strictly "cache-aware" in the sense that the server knows for sure if the asset is cached on the client side, but the logic follows. If you don't have the luxury of being able to use a web server like [H2O](https://h2o.examp1e.net/configure/http2_directives.html#http2-casper) or the [H2PushDiarySize directive](https://httpd.apache.org/docs/2.4/mod/mod_http2.html#h2pushdiarysize) for Apache's `mod_http2` module, this solution may work well enough for your purposes.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/krenor/http2-pusher/blob/master/CONTRIBUTING.md) for more information.

Licence
-------

[](#licence)

The MIT License. Please see [LICENSE](https://github.com/krenor/http2-pusher/blob/master/CONTRIBUTING.md) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

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

Unknown

Total

1

Last Release

3011d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7869e672fe6c7058ed052d6dd48be784cbcb0a38e334191ebce96aaa0e777483?d=identicon)[Krenor](/maintainers/Krenor)

---

Top Contributors

[![krenor](https://avatars.githubusercontent.com/u/13726968?v=4)](https://github.com/krenor "krenor (19 commits)")

---

Tags

middlewarelaravelhttp2laravel middlewarecache digestkrenorhttp2 pushhttp2 cache

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/krenor-http2-pusher/health.svg)

```
[![Health](https://phpackages.com/badges/krenor-http2-pusher/health.svg)](https://phpackages.com/packages/krenor-http2-pusher)
```

###  Alternatives

[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

71510.9M66](/packages/laravel-mcp)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[omniphx/forrest

A Laravel library for Salesforce

2724.4M8](/packages/omniphx-forrest)[matthewbdaly/laravel-etag-middleware

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

64326.0k2](/packages/matthewbdaly-laravel-etag-middleware)

PHPackages © 2026

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