objects

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.

One per request, reached as `$app->kept`.
$kept Phlat\Kept 12 methods
Show
  • 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.

Null when it is not allowed or the entry is not held.
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

key

$kept->key(): string

Returns string

phlat/src/Kept.php:67
$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.

Null when it read the session (a flash message, a CSRF token), which is never kept.
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->page(Page $page): ?array

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().

Parameters (1)
$page Page

Returns ?array

phlat/src/Kept.php:37
$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.

A signed-in visitor's is `private`, so no shared cache holds it at all. Returns what to send: $html, or nothing for a 304.
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.

Its life is the view's, cut short by the shortest inline {cache} region inside it.
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