oxhq/cachelet-request

Request and response caching integration for Cachelet.

Maintainers

Package info

github.com/oxhq/cachelet-request

Homepage

Issues

pkg:composer/oxhq/cachelet-request

Statistics

Installs: 0

Dependents: 1

Suggesters: 0

Stars: 0

v0.2.2 2026-04-24 23:35 UTC

This package is auto-updated.

Last update: 2026-04-25 09:51:10 UTC


README

Read-only split of the Cachelet monorepo package at packages/cachelet-request.

Request and response caching integration for Cachelet.

Install

composer require oxhq/cachelet-request

Features

  • Route ->cachelet() integration
  • Middleware-driven response caching
  • scope(...) support on request cache profiles
  • Vary by query string, headers, locale, and authenticated user
  • Namespace invalidation for request caches
  • Canonical module = request coordinates and telemetry

Example

use Oxhq\Cachelet\ValueObjects\CacheScope;

$scope = /* CacheScope instance for the intervention boundary */;

Route::get('/users', UserIndexController::class)
    ->name('users.index')
    ->cachelet(600, [
        'vary' => ['query' => true, 'auth' => true],
        'namespace' => 'users',
        'scope' => $scope,
    ]);

If you do not define a scope explicitly, cachelet-request infers one from the route or namespace prefix boundary it already uses for request-cache grouping.

Request Contract

cachelet-request caches only configured cacheable methods and statuses. In 0.2.x that means:

  • methods default to GET and HEAD
  • statuses default to 200
  • streamed and binary responses are bypassed
  • non-cacheable refresh callbacks keep the last cacheable payload during SWR instead of replacing it with an invalid response shape

Vary dimensions are explicit:

  • query string, full or partial
  • selected headers
  • authenticated user identity vs guest
  • locale
  • custom payload callback

Use namespace or route-prefix invalidation for request caches. Do not assume CDN/proxy cache orchestration or fragment caching in this module.