tomkeyte/laravel-http2-push 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tomkeyte/laravel-http2-push

Composer 安装命令:

composer require tomkeyte/laravel-http2-push

包简介

A cache aware provider for HTTP2 Push within a Laravel application

README 文档

README

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

Latest Version on Packagist Total Downloads

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:

composer require tomkeyte/laravel-http2-push

Publish the configuration (recommended):

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

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):
'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

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

* Every GET request that is routed through the web middleware

Testing

composer test

Generate a code coverage report with

composer test-coverage

Requires an applicable code coverage driver, such as xdebug

Credits

License

The MIT License (MIT). Please see License File for more information.

tomkeyte/laravel-http2-push 适用场景与选型建议

tomkeyte/laravel-http2-push 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 61 次下载、GitHub Stars 达 81, 最近一次更新时间为 2020 年 11 月 02 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「seo」 「laravel」 「push」 「http2」 「laravel-http2-push」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 tomkeyte/laravel-http2-push 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tomkeyte/laravel-http2-push 我们能提供哪些服务?
定制开发 / 二次开发

基于 tomkeyte/laravel-http2-push 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 61
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 81
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 81
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-02