wyrihaximus/react-http-middleware-response-cache-session-cache-configuration

缓存配置,防止任何具有活动会话的请求或响应与缓存交互

2.0.0 2018-09-03 12:04 UTC

This package is auto-updated.

Last update: 2024-09-06 06:48:08 UTC


README

Build Status Latest Stable Version Total Downloads Code Coverage License PHP 7 ready

安装

要通过Composer安装,请使用以下命令,它将自动检测最新版本并将其绑定到^

composer require wyrihaximus/react-http-middleware-response-cache-session-cache-configuration

wyrihaximus/react-http-middleware-response-cachewyrihaximus/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)

版权所有 © 2018 Cees-Jan Kiewiet

在此,任何人免费获得本软件及其相关文档文件(“软件”)的副本,均可不受限制地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件的副本,并允许向软件提供副本的人员这样做,前提是遵守以下条件

上述版权声明和本许可声明应包含在软件的所有副本或实质性部分中。

本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、适用于特定用途和侵权保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论是基于合同、侵权或其他方式,无论该索赔、损害或其他责任是否因软件或软件的使用或其他方式产生、产生于或与软件有关。