定制 geniussystems-np/cache-middleware 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

geniussystems-np/cache-middleware

最新稳定版本:1.0.1

Composer 安装命令:

composer require geniussystems-np/cache-middleware

包简介

Cache Middleware for Resources

README 文档

README

We use two middleware for cache, one for serving response from cache and another for generating cache.

  • ServeCachedResponse
    • The only job will be serve the response from cache if available
    • This middleware should be below the Authentication in the Middleware stack
  • CacheReponse
    • This middleware should analyze the response for it’s cacheability by checking the cache headers
    • If the response is cacheable, it should cache the response in configured cache store(Redis)
    • Currently, We are using only cache-control directive to cache the response

The package uses Laravel Cache to store and serve response. Any response having cache-control directive with max-age will be cached for duration defined in max-age parameter.

Installing the package using composer

composer require geniussystems-np/cache-middleware

Once the package is installed, enable the Middleware in app/Http/Kernel.php and add to your required middleware group.

protected $middleware = [
        \App\Http\Middleware\TrustHosts::class,
        \App\Http\Middleware\TrustProxies::class,
        \Fruitcake\Cors\HandleCors::class,
        \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
        .
        .
        \GeniusSystems\Http\Middleware\ServeCachedResponse::class,
        .
        .
        \GeniusSystems\Http\Middleware\CacheResponse::class,
  ];

ServeCacheResponse should be after authentication middleware since it doesn’t pass the request to other middleware in the stack if there’s a response. Above code asumes you’re enabling cache-middleware for all the routes. For specific routes, you need to added the middleware to it’s respective group and enable middleware in route.

统计信息

  • 总下载量: 5.27k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-09-29