switon/http-cache

Redis-backed per-action HTTP caching with request-derived keys and ETag revalidation for Switon Framework

Maintainers

Package info

github.com/switon-php/http-cache

Documentation

pkg:composer/switon/http-cache

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-06 13:43 UTC

This package is auto-updated.

Last update: 2026-06-07 05:12:33 UTC


README

HTTP Cache CI PHP 8.3+

Switon's page cache filter for Redis-backed action caching and conditional HTTP responses.

Highlights

  • Action-level page cache: #[PageCache] marks controller actions cacheable with a TTL.
  • Redis-backed storage: cached responses are stored in Redis.
  • Request-aware keys: keys can use selected request fields or fixed values.
  • Conditional responses: cache hits can still support 304 Not Modified.
  • Scoped lookup: cache lookup applies only to eligible request methods.

Installation

composer require switon/http-cache

Quick Start

use Switon\HttpCache\Attribute\PageCache;
use Switon\Routing\Attribute\GetMapping;

class ProductController
{
    #[GetMapping('/products')]
    #[PageCache(ttl: 600, key: ['category', 'page'])]
    public function listAction(string $category = 'all', int $page = 1): array
    {
        return [
            'category' => $category,
            'page' => $page,
            'items' => $this->loadProducts($category, $page),
        ];
    }
}

Docs: https://docs.switon.dev/latest/http-cache

License

MIT.