overtrue/laravel-passport-cache-token
Caches Laravel Passport access tokens so API authentication no longer hits the database on every request. This drop-in package stores token data in your configured cache store, cutting query load and speeding up response times in high-traffic applications.
What this package is. overtrue/laravel-passport-cache-token is a thin caching decorator around Laravel Passport's token repository. Instead of hitting the oauth_access_tokens table on every bearer-token-authenticated request, it resolves token → client/user from a configured cache store. For any API with meaningful authenticated traffic, that is a direct reduction of one indexed read per request on the hottest path.
Architecture fit. It slots in at the resource-server boundary, not the authorization-server boundary, so it does not change token issuance, grants, scopes, or refresh flow. That is the right seam: it is additive, it does not fork Passport, and it can be removed by unregistering a service provider. The trade-off is that it is an implicit dependency on Passport's internal TokenRepository contract — if Passport changes that contract, the package breaks in a way that surfaces as authentication failures, not as a compile error.
What 3.2.0 actually changes. One thing: Laravel 10 support (PR #19, first-time contributor). No API changes, no config changes, no deprecations, no breaking changes. Read the release note honestly — the value here is compatibility, not capability. For a team already on Laravel 10 with Passport, this release is what makes the package installable at all; for a team on Laravel 9, it is a no-op. The more informative signal is the cadence: Laravel 10 shipped in February 2023, and this support arrived as a community PR rather than maintainer work. That tells you the bus factor and the responsiveness profile you are buying into.
Technical risk.
Token models, and any existing token-caching or introspection layer already in place.Key questions to put to the maintainer or resolve in a spike.
Stack fit. Good where the stack is Laravel 9/10 + Passport + a shared cache (Redis or Memcached). Poor fit where the cache is per-node file/array, where token volume is low enough that the DB read is not a bottleneck, or where the org has a hard requirement for vendor-backed dependencies — this is a single-maintainer community package.
Migration path. Purely additive and reversible:
composer require overtrue/laravel-passport-cache-token on a branch; confirm the resolved Passport constraint matches what you run in production.Compatibility checks before merge. PHP 8.1+ floor (Laravel 10 requirement), Passport major version, Redis client/version, and whether any existing middleware or custom guard reads tokens in a way that bypasses the decorated repository. Also confirm the package's service provider load order relative to PassportServiceProvider.
Sequencing.
oauth_access_tokens read volume, and run a cache-flush-mid-traffic test to observe failure behavior.Maintenance. Low code footprint, but the maintenance cost is not in the LOC — it is in the upgrade tax. This release is the pattern: a framework major version ships, and you wait on a volunteer PR. Budget for the package acting as a lagging indicator on every Laravel upgrade, and pin it in your dependency policy so upgrades are deliberate. A single-maintainer dependency touching authentication belongs on a quarterly review list, not a set-and-forget list.
Support. Community-only, no SLA, no security disclosure process documented that I can see. The mitigating factor is the blast radius: because it is a cache decorator, the worst-case remediation is always "disable it and fall back to the database," which is slow but correct. Make sure the on-call runbook says exactly that, and that disabling it is a config change rather than a deploy.
Scaling. This is where the package earns its place. Token validation is per-request and perfectly cacheable, so the win scales linearly with authenticated RPS: high-traffic APIs see a large drop in primary-database read load with a corresponding improvement in p99 on authenticated endpoints. It does not help write paths, issuance, or refresh — only validation. Model the cache memory cost against the active-token population and TTL before assuming Redis headroom is free.
Failure modes to instrument.
Ramp-up. Half a day for a mid-level Laravel engineer to install and configure; one to two days to do it safely, because the real work is understanding Passport's token lifecycle and proving the invalidation story. The package's README is not a substitute for that. Assign it to someone who has already debugged Passport internals, and pair the rollout with written tests for revoke, logout, and expired-token paths — those tests, not the package, are the durable artifact.
Recommendation. Adopt on Laravel 10 services with high authenticated read volume and a shared Redis cache, contingent on the invalidation question being answered satisfactorily in the spike. Do not adopt on low-traffic services, where the added dependency and upgrade tax buy nothing. For services still on Laravel 9, treat 3.2.0 as the gate that makes a future Laravel 10 upgrade viable, not as a reason to act now.
How can I help you explore Laravel packages today?