Expand description
The response cache, as the PHP package’s ResponseCache middleware and #[CacheResponse]
attribute do it: a route opts in, its successful GET responses are kept in a Laravel cache
store, and later requests are answered from the store with X-Response-Cache: hit. Entries
are tagged, and flush drops every entry with any of the tags it is given.
The cached body is the latest version’s, from before the version changes run, so every
version shares an entry. Entries are scoped to the API client (guest without one) unless the
route marks them CacheResponse::shared.
A user signed in through Laravel’s own guards (the session guard, or a RequestGuard run by
Authenticate::via) rather than as an API client has no client to scope an entry to, and the
framework says only that someone is signed in, not who. Such a request skips the cache unless
the route’s entries are shared: it is neither answered from the guest entry nor stored in it.
Structs§
- Cache
Response - Route middleware that caches a route’s successful GET responses, as
#[CacheResponse]does in PHP. Tags may name route parameters, such asorders:{order}.
Constants§
- HEADER
- The header that says whether the store answered the request.
Functions§
- cache_
key - The request’s response cache key and what it is made of, as the PHP package’s
CacheKeymakes them: the method (HEAD as GET), path, pinned version, client (guestwithout one) and query, withincludeandfieldsvalues in any order. The key is the same in both packages. - flush
- Drops every cached response stored with any of the tags, such as
ordersandorders:5after order 5 changes. Uses the default cache store, as the PHP package’sresponse_cache.storedoes when it is null;flush_innames another. - flush_
in flushin the named cache store.