Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Psr6 Symfony Http Cache Store

Psr6 Symfony Http Cache Store Laravel Package

toflar/psr6-symfony-http-cache-store

PSR-6 compatible store for Symfony HttpCache using Symfony Cache + Lock. Adds tag-based invalidation, automatic pruning of expired entries, configurable adapters/locks, and BinaryFileResponse support. Avoids unbounded cache directory growth.

View on GitHub
Deep Wiki
Context7

An alternative store implementation for Symfony's HttpCache reverse proxy that supports auto-pruning of expired entries and cache invalidation by tags.

Frequently asked questions about Psr6 Symfony Http Cache Store
How do I integrate this package into a Laravel application for HTTP caching?
This package isn’t Laravel-specific, but you can use it with Symfony’s HttpCache in Laravel via a bridge like `symfony/http-kernel`. Configure it in `index.php` (or `public/index.php`) by wrapping your kernel with `HttpCache` and passing a `Psr6Store` instance. Ensure your PSR-6 cache adapter (e.g., Redis, APCu) is tag-aware if you need invalidation by tags.
Does this work with Laravel’s built-in cache system?
No, this package is designed for Symfony’s HttpCache, not Laravel’s cache system. However, you can use it alongside Laravel’s cache (e.g., Redis) by configuring the `Psr6Store` to delegate to Laravel’s PSR-6-compatible cache adapter. This is useful for reverse proxy caching or edge caching in Laravel apps using Symfony components.
What Laravel versions and PHP versions are supported?
This package requires PHP 8.1+ and Symfony 6/7/8. Laravel compatibility depends on your Symfony integration. For Laravel 9+ (PHP 8.1+), it works seamlessly if you’re using Symfony components. For older Laravel versions, ensure your PHP and Symfony dependencies align with the package’s requirements (e.g., Symfony 5.4+ for Laravel 8).
How do I configure auto-pruning for expired cache entries?
Auto-pruning is enabled by default when using the `PrunableInterface`-compatible adapters (like Symfony’s filesystem cache). No extra configuration is needed for basic pruning. For custom PSR-6 adapters, ensure they implement `PrunableInterface` or wrap them with a pruning layer. Pruning runs automatically during cache operations but can be triggered manually via the adapter’s `prune()` method.
Can I use Redis or another PSR-6 cache adapter instead of the filesystem?
Yes, you can configure any PSR-6-compatible cache adapter (e.g., Redis, Doctrine Cache, APCu) by passing it via the `cache` option in the `Psr6Store` constructor. For tag-based invalidation, ensure your adapter implements `TagAwareAdapterInterface`. Locking can also be customized, but the default filesystem lock works for most use cases.
Will this package work with Laravel’s route cache or opcode cache?
No, this package is for HTTP-level caching (e.g., reverse proxy caching, API responses) and isn’t designed for Laravel’s route cache or opcode cache (OPcache). It’s best suited for caching full HTTP responses, like those generated by Symfony’s HttpCache or a Laravel middleware layer using Symfony components.
How do I handle cache invalidation by tags in Laravel?
To invalidate cache by tags, configure your `Psr6Store` with a `TagAwareAdapterInterface`-compatible PSR-6 adapter (e.g., Symfony’s Redis cache). Then, use the adapter’s `invalidateTags()` method or Symfony’s `CacheItemPoolInterface` to clear tagged entries. In Laravel, you’d typically trigger this from a service or event listener tied to model updates or route changes.
Are there performance concerns with auto-pruning in high-traffic Laravel apps?
Auto-pruning adds minimal overhead during cache operations, but frequent pruning in high-write scenarios (e.g., thousands of entries) may impact performance. Test with your PSR-6 adapter under load. For Redis or database backends, pruning is often faster than filesystem-based pruning. Monitor cache hit/miss ratios to optimize pruning intervals or switch to a distributed cache like Redis for scalability.
Can I use this for caching API responses in Laravel Sanctum or Passport?
Yes, this package is ideal for caching API responses in Laravel Sanctum or Passport, especially if you’re using Symfony’s HttpCache or a similar middleware layer. Configure the `Psr6Store` to cache responses and invalidate tags when user data (e.g., tokens, roles) changes. Ensure your PSR-6 adapter supports binary data if responses include large payloads or files.
What alternatives exist for HTTP caching in Laravel if I don’t want to use Symfony components?
Alternatives include Laravel’s built-in cache system with middleware (e.g., `Cache::remember`), packages like `spatie/laravel-cache-control` for HTTP caching headers, or `illuminate/cache` with Redis/Memcached. For PSR-6-based HTTP caching, consider `stash/stash` or `cache/array-adapter` for lightweight solutions. However, none offer the same tag-based invalidation or auto-pruning as this package when paired with Symfony’s HttpCache.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor