Kept
What this request has to say about keeping its response: the page cache's entry, who may share it, and how the response revalidates.
- begin Starts the reads this request is judged by: the router's and the render's, see level().
- clientFor What a browser may keep a response for: the $client the author allowed, cut to what is left of the entry at $key so it never outlives the copy a save clears.
- fragment The request's `:block` was served from or stored in $cache under $key, so its response revalidates like a kept page (ETag, 304), or with `$client` seconds, is kept by the browser (see clientFor()).
- key
- level Who a render begun at $mark may be shared with (Cache::LEVELS): everyone (`none`) when it asked nothing about the visitor, their role when it asked what they hold, only them when it asked who they are.
- limit Cuts what the browser may keep to what is left of this page's entry in $cache.
- mark What a kept render is checked against: take it when the render begins and pass it to level() when it ends.
- page The cache holding this request's page render and the seconds to keep it, or null unless the view opted in with `cache` and the request is a plain GET of the whole page, see uncacheable().
- revalidate Sets the cache headers of a response built from $html: a kept page (or a fragment served from the cache) revalidates on every use (`no-cache` plus an ETag) and answers 304 to a validator that still matches, so nothing downstream can serve it stale.
- shorten An inline {cache} region took part in this render: the page it is in must not outlive it.
- store Keeps a render for everyone its reads let share it (see level()): a 200 that read no session and set no cookie or htmx header, else returns why not.
- uncacheable Why this request is kept out of the caches, or null: what the Clockwork Cache panel shows for a view that opted in and was skipped.
Methods
$kept->begin(): void
Starts the reads this request is judged by: the router's and the render's, see level().
phlat/src/Kept.php:75
$kept->clientFor(?int $client, Cache $cache, string $key): ?int
What a browser may keep a response for: the $client the author allowed, cut to what is left of the entry at $key so it never outlives the copy a save clears.
Parameters (3)
| $client | ?int | |
| $cache | Cache | |
| $key | string |
Returns ?int
phlat/src/Kept.php:124
$kept->fragment(?int $client, Cache $cache, string $key): void
The request's `:block` was served from or stored in $cache under $key, so its response revalidates like a kept page (ETag, 304), or with `$client` seconds, is kept by the browser (see clientFor()).
Parameters (3)
| $client | ?int | |
| $cache | Cache | |
| $key | string |
phlat/src/Kept.php:117
$kept->level(array $mark): ?string
Who a render begun at $mark may be shared with (Cache::LEVELS): everyone (`none`) when it asked nothing about the visitor, their role when it asked what they hold, only them when it asked who they are.
Parameters (1)
| $mark | array |
Returns ?string
phlat/src/Kept.php:104
$kept->limit(Cache $cache): void
Cuts what the browser may keep to what is left of this page's entry in $cache.
Parameters (1)
| $cache | Cache |
phlat/src/Kept.php:132
$kept->mark(): array
What a kept render is checked against: take it when the render begins and pass it to level() when it ends.
Returns array
phlat/src/Kept.php:98
$kept->revalidate(string $html, bool $page): string
Sets the cache headers of a response built from $html: a kept page (or a fragment served from the cache) revalidates on every use (`no-cache` plus an ETag) and answers 304 to a validator that still matches, so nothing downstream can serve it stale.
Parameters (2)
| $html | string | |
| $page | bool |
Returns string
phlat/src/Kept.php:154
$kept->shorten(int $seconds): void
An inline {cache} region took part in this render: the page it is in must not outlive it.
Parameters (1)
| $seconds | int |
phlat/src/Kept.php:138
$kept->store(Cache $cache, int $ttl, string $html): ?string
Keeps a render for everyone its reads let share it (see level()): a 200 that read no session and set no cookie or htmx header, else returns why not.
Parameters (3)
| $cache | Cache | |
| $ttl | int | |
| $html | string |
Returns ?string
phlat/src/Kept.php:81
$kept->uncacheable(): ?string
Why this request is kept out of the caches, or null: what the Clockwork Cache panel shows for a view that opted in and was skipped.
Returns ?string
phlat/src/Kept.php:144