Download the PHP package tomkeyte/laravel-http2-push without Composer
On this page you can find all versions of the php package tomkeyte/laravel-http2-push. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tomkeyte/laravel-http2-push
More information about tomkeyte/laravel-http2-push
Files in tomkeyte/laravel-http2-push
Package laravel-http2-push
Short Description A cache aware provider for HTTP2 Push within a Laravel application
License MIT
Homepage https://github.com/tomkeyte/laravel-http2-push
Informations about the package laravel-http2-push
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, courtesy of Merj Ltd
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
Install the package via composer:
Publish the configuration (recommended):
Server config
IMPORTANT! HTTP2 Push via the Link header must be enabled for your webserver
Instructions for nginx and apache.
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):
- Optionally, supply an array of resources that should be pushed on every request*
In your blade templates, push the resources:
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
* Every GET request that is routed through the web middleware
Testing
Generate a code coverage report with
Requires an applicable code coverage driver, such as xdebug
Credits
License
The MIT License (MIT). Please see License File for more information.