wyrihaximus / react-http-middleware-response-cache-session-cache-configuration
缓存配置,可防止任何具有活动会话的请求或响应与缓存交互
2.0.0
2018-09-03 12:04 UTC
Requires
Requires (Dev)
- api-clients/test-utilities: ^4.2
- ringcentral/psr7: ^1.2.2
This package is auto-updated.
Last update: 2024-09-06 06:48:08 UTC
README
安装
要通过 Composer 安装,请使用以下命令,它将自动检测最新版本并将其与 ^
绑定。
composer require wyrihaximus/react-http-middleware-response-cache-session-cache-configuration
为 wyrihaximus/react-http-middleware-response-cache
和 wyrihaximus/react-http-middleware-session
提供缓存配置装饰器。当请求通过具有活动会话时,将跳过缓存,并将请求传递给链中的下一个中间件。当响应通过具有活动会话时,响应不会被存储在缓存中。中间件的顺序对于此缓存配置装饰器的正确工作至关重要。以下示例显示了正确的顺序。
使用方法
$server = new Server([ /** Other middleware */ new SessionMiddleware('Floki'), // Note that the order here is important. The session middleware MUST attach the session before the ResponseCacheMiddleware new ResponseCacheMiddleware( new SessionCacheConfiguration( new CacheConfiguration( [ '/', '/robots.txt', '/favicon.ico', '/cache/***', // Anything that starts with /cache/ in the path will be cached '/api/???', // Anything that starts with /cache/ in the path will be cached (query is included in the cache key) ], [ // Optional, array with headers to include in the cache 'Content-Type', ] ) ), new ArrayCache() // Optional, will default to ArrayCache but any CacheInterface cache will work. ), /** Other middleware */ ]);
许可证
MIT 许可证 (MIT)
版权所有 (c) 2018 Cees-Jan Kiewiet
特此授予任何获得此软件及其相关文档文件(“软件”)副本的任何人,无需支付费用,自由地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,并允许向提供软件的人授权此类行为,前提是遵守以下条件
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、特定目的的适用性和非侵权性保证。在任何情况下,作者或版权所有者都不应对任何索赔、损害或其他责任负责,无论是基于合同、侵权或其他方式,无论是由于软件或软件的使用或其他方式而产生的。