PHPackages                             tomkeyte/laravel-http2-push - 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. tomkeyte/laravel-http2-push

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

tomkeyte/laravel-http2-push
===========================

A cache aware provider for HTTP2 Push within a Laravel application

1.1.0(5y ago)81612[1 PRs](https://github.com/TomKeyte/Laravel-HTTP2-Push/pulls)MITPHPPHP &gt;=7.3

Since Nov 2Pushed 4y ago2 watchersCompare

[ Source](https://github.com/TomKeyte/Laravel-HTTP2-Push)[ Packagist](https://packagist.org/packages/tomkeyte/laravel-http2-push)[ Docs](https://github.com/tomkeyte/laravel-http2-push)[ RSS](/packages/tomkeyte-laravel-http2-push/feed)WikiDiscussions main Synced 1mo ago

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

A cache-aware HTTP2 Server Push implementation, for the Laravel framework

For a comprehensive study of the impacts of HTTP2 Push, check out this [article](https://merj.com/blog/study-of-http2-and-push-coverage-top-100k-websites), courtesy of [Merj Ltd](https://merj.com)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a56f780d9907a8e773e07d8451861037b18b429f348dd3601052f698be351d6e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f6d6b657974652f6c61726176656c2d68747470322d707573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tomkeyte/laravel-http2-push)[![Total Downloads](https://camo.githubusercontent.com/a617a3056b7496fd5a0678b255b696e8cb35517741bc4e08b2d50cdb2924a40d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f6d6b657974652f6c61726176656c2d68747470322d707573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tomkeyte/laravel-http2-push)

HTTP2 Push is hard! This package makes it easy, providing a simple blade directive that informs clients "Hey, I know you've only asked for a HTML document, but I already know you'll need this stylesheet, so just start downloading them now".

Resources are pushed once per cached-lifetime.

i.e, say you have a stylesheet with a cache length set via the `Cache-Control` header, with an expiry length of 28 days. The package will initially push the resource, and also set a cookie to track (per resource) whether it has been sent, and therefore cached - after all, there's no need to push a resource that the browser has already cached (Hence the motivation behind this package).

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

[](#installation)

Install the package via composer:

```
composer require tomkeyte/laravel-http2-push
```

Publish the configuration (recommended):

```
php artisan vendor:publish --provider="TomKeyte\LaravelHttp2Push\Http2PushServiceProvider"
```

### Server config

[](#server-config)

**IMPORTANT! HTTP2 Push via the Link header must be enabled for your webserver**

Instructions for [nginx](https://www.nginx.com/blog/nginx-1-13-9-http2-server-push/#configuring) and [apache](https://httpd.apache.org/docs/2.4/mod/mod_http2.html#h2push).

Usage
-----

[](#usage)

Check the `http2push.php` config file to set default expiry lengths based on your setup. N.B, expiry lengths throughout the package are expressed in days - a value of `-1` indicates no cookie should be set, resulting in a push on all requests.

The setup is as following:

- Set the global cookie expiry limit with `cookie_expires_in`
- Set the cookie expiry for certain file types (these override the global limit):

```
'cookie_expire_types' => [
    'font' => 90,
    'script' => 27,
    'style' => 24,
    'image' => 30,
],
```

- Optionally, supply an array of resources that should be pushed on every request\*

```
'always' => [
    '/js/app.js', # A simple string
    [
        'src' => '/css/app.css', # Or an array, containing the src & expiry time
        'expires' => '90',
    ],
],
```

In your blade templates, push the resources:

```
// use default cookie expiry lengths
@h2push('/css/app.css')
```

```
// specify a cookie expiry length of 60 days, for this resource only
@h2push('/js/app.js', 60)
```

It is recommended you version your resources, so that the package can track whether it needs to re-push them. This package works well with [laravel-mix](https://github.com/JeffreyWay/laravel-mix)

```
@h2push( mix('/css/app.css') )
```

\* *Every GET request that is routed through the web middleware*

### Testing

[](#testing)

```
composer test
```

Generate a code coverage report with

```
composer test-coverage

```

*Requires an applicable code coverage driver, such as xdebug*

Credits
-------

[](#credits)

- [Tom Keyte](https://github.com/tomkeyte)
- [Merj Ltd](https://merj.com)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.5% 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 ~49 days

Total

3

Last Release

1916d ago

PHP version history (2 changes)1.0.0PHP ^7.3

1.1.0PHP &gt;=7.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/396c3af01de851b5b86956d5b38dee1f8c3358c6a059ba63809952da2f47b5b8?d=identicon)[tomkeyte](/maintainers/tomkeyte)

---

Top Contributors

[![TomKeyte](https://avatars.githubusercontent.com/u/15073832?v=4)](https://github.com/TomKeyte "TomKeyte (7 commits)")[![Erulezz](https://avatars.githubusercontent.com/u/6772197?v=4)](https://github.com/Erulezz "Erulezz (1 commits)")

---

Tags

laravelpushhttp2seolaravel-http2-push

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/tomkeyte-laravel-http2-push/health.svg)

```
[![Health](https://phpackages.com/badges/tomkeyte-laravel-http2-push/health.svg)](https://phpackages.com/packages/tomkeyte-laravel-http2-push)
```

###  Alternatives

[symfony/web-link

Manages links between resources

1.4k99.0M250](/packages/symfony-web-link)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[laravel-shift/curl-converter

A command line tool to convert curl requests to Laravel HTTP requests.

935.3k](/packages/laravel-shift-curl-converter)[illuminatech/data-provider

Allows easy build for DB queries from API requests

4413.3k](/packages/illuminatech-data-provider)[onlime/laravel-http-client-global-logger

A global logger for the Laravel HTTP Client

1935.1k](/packages/onlime-laravel-http-client-global-logger)[dragon-code/laravel-http-logger

Logging incoming HTTP requests

319.8k3](/packages/dragon-code-laravel-http-logger)

PHPackages © 2026

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