2017 © Pedro PelĂĄez
 

library http2-pusher

Cache aware HTTP/2 pushing for Laravel.

image

krenor/http2-pusher

Cache aware HTTP/2 pushing for Laravel.

  • Tuesday, February 13, 2018
  • by Krenor
  • Repository
  • 3 Watchers
  • 16 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Cache aware HTTP/2 pushing for Laravel

Packagist ![Travis][icon-travis] Quality ![Coverage][icon-code-coverage] Dependencies ![Downloads][icon-downloads] License, (*1)

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), (*2)

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 currently under discussion at the IETF HTTP Working Group. (Source), (*3)

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., (*4)

Installation

You can install the package via composer:, (*5)

composer require krenor/http2-pusher

Laravel 5.5 uses Package Auto-Discovery, so it doesn't require you to manually add the ServiceProvider to your providers array configuration., (*6)

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, (*7)

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., (*8)

Note: Only these extensions are currently supported., (*9)

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 or the H2PushDiarySize directive for Apache's mod_http2 module, this solution may work well enough for your purposes., (*10)

Contributing

Please see CONTRIBUTING for more information., (*11)

Licence

The MIT License. Please see LICENSE for more information., (*12)

The Versions

13/02 2018

dev-develop

dev-develop

Cache aware HTTP/2 pushing for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel middleware http2 cache digest krenor laravel 5.5 laravel middleware http2 push http2 cache

13/02 2018

dev-master

9999999-dev

Cache aware HTTP/2 pushing for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel middleware http2 cache digest krenor laravel 5.5 laravel middleware http2 push http2 cache

13/02 2018

1.0.0

1.0.0.0

Cache aware HTTP/2 pushing for Laravel.

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel middleware http2 cache digest krenor laravel middleware http2 push http2 cache