Download the PHP package contenir/cache-mezzio without Composer
On this page you can find all versions of the php package contenir/cache-mezzio. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download contenir/cache-mezzio
More information about contenir/cache-mezzio
Files in contenir/cache-mezzio
Package cache-mezzio
Short Description Mezzio (PSR-15) adapter for contenir/contenir-page-cache: a full-page output cache middleware controlled by the Contenir admin.
License MIT
Informations about the package cache-mezzio
contenir/contenir-page-cache-mezzio
Formerly contenir/contenir-cache-mezzio, and before that contenir/cache-mezzio.
See UPGRADE-page-cache.md to move from either.
Mezzio (PSR-15) adapter for contenir/contenir-page-cache.
A full-page output cache middleware, controlled by the Contenir admin's
Page Cache screen. It is the sibling of
contenir/contenir-cache-laminas-mvc:
same pagecache config key, same cache_with_* / make_id_with_* options,
same route overrides, so a site's settings mean the same thing on either
framework.
Requirements
- PHP 8.3, 8.4 or 8.5
contenir/contenir-page-cache2.0+,contenir/contenir-config2.1+laminas/laminas-diactoros3.x, PSR-7, PSR-11, PSR-15, PSR-16 and PSR-20- Optional:
laminas/laminas-cache3.x or 4.x, for the storage the admin's purge buttons understand (see Storage and purging)
The 0.x releases remain available from the 0.x branch and v0.* tags; see
UPGRADE-2.0.md.
Install
laminas/laminas-component-installer adds Contenir\PageCache\Mezzio\ConfigProvider
to config/config.php. Without it, add the provider yourself:
The provider registers PageCacheMiddleware (and the CachePolicy and
PageStore it is built from) and declares the pagecache defaults, with
caching off.
Configure
Point the middleware at a cache service and set the site's defaults:
Every key, the options and the route overrides are described in docs/configuration.md.
Pipe it
- After maintenance, so a site in maintenance answers 503 rather than a cached page (and a 503 is never stored).
- After session, if the site pipes one, so the
sessionattribute is there to recognise a logged-in user. Without it, the session cookie alone stands in for the session. - Before routing, so a hit skips routing and dispatch altogether.
- The clear before the page cache, so the CMS's request to clear the site's caches is answered before anything is read from them.
Clearing from the CMS
The CMS clears the site's caches by posting a signed token to the site's
fixed /api/cache (the protocol is contenir/contenir-page-cache's
Clear\ClearProtocol). CacheClearMiddleware checks it, then clears the page
store and each other cache the site lists, through their own stores: a PSR-16
cache's clear(), or a laminas-cache storage's own namespace only, so caches
sharing a directory are left alone. The page store's generation moves on with
it, so a page rendered from old data while the clear lands is never served.
When the site caches its merged configuration under config_cache_path (as
the Mezzio skeleton does), the clear removes that file too, so settings the CMS
wrote to config/autoload are read on the next request.
The keys default to the ones previews use, so a site holds one secret for
both. With no clear configured, the middleware passes everything through and
the endpoint does not exist. It answers 204 once everything is cleared,
500 naming what could not be (config, pages or a listed cache), 405 to
anything but a POST, and 400, 401 or 409 to a refused token.
Documentation
- Configuration: every
pagecachekey, thecache_with_*/make_id_with_*options and route overrides. - How it works: bypass, hit and miss rules, and why the admin's file is read on every request.
- Extending: vetoing a response, response mutators and the public API.
- Storage and purging: PSR-16 and laminas-cache storages, the TTL pitfall and the admin's purge buttons.
Public API
| Type | Purpose |
|---|---|
ConfigProvider |
Registers the four factories below and the pagecache defaults (getDependencies(), getPageCacheDefaults()). |
PageCacheMiddleware |
The PSR-15 middleware: (CachePolicy $policy, PageStore $store, list<ResponseMutatorInterface> $mutators = []). veto(ResponseInterface) marks a response as not to be stored; VETO_HEADER and STATUS_HEADER name the headers it uses. |
CachePolicy |
Decides whether a request may use the cache and under which key: ticketFor(ServerRequestInterface): ?CacheTicket. USER_ATTRIBUTE is the request attribute that marks a logged-in user. |
CacheTicket |
The key and per-path TTL one request reads and writes. |
PageStore |
Reads and writes pages in a PSR-16 cache: fetch(CacheTicket), save(CacheTicket, ResponseInterface), stamped(CacheTicket) for the store's current generation, and clear(), which empties it and moves the generation on. |
CacheClearMiddleware |
Answers the CMS's signed clear at /api/cache: (?ClearVerifier $verifier, PageStore $store, array<string, CacheInterface> $caches = [], ?ConfigCacheFile $config = null). |
ConfigCacheFile |
The site's cached merged configuration, which clear() removes (and drops from OPcache). |
CacheResult |
Hit, Miss or Bypass, handed to every mutator. |
ResponseMutatorInterface |
The extension point for per-request changes after storage. |
SystemClock |
The PSR-20 wall clock PageStore uses by default. |
Contenir\PageCache\Repository\LayeredFileRepository |
From contenir-page-cache: the admin's file laid over the site's defaults (a CacheControlRepositoryInterface). |
PageCacheMiddlewareFactory, CachePolicyFactory, PageStoreFactory, CacheClearMiddlewareFactory |
Build the services above from config['pagecache']; invalid configuration throws RuntimeException. CachePolicyFactory::DEFAULT_FILE is the admin file's path relative to the working directory. |
ActiveOptions, CacheKeyGenerator, ClearKeys, ClearOptions,
ClearSetting, PageCacheConfig, PageCodec, PageGeneration,
SessionInspector and StoredResponse are internal.
Development
The QA toolchain is contenir/contenir-qa-tools.
Mago is a standalone binary, installed
separately (brew install mago).
License
MIT. See LICENSE.
All versions of cache-mezzio with dependencies
contenir/contenir-page-cache Version ^2.0.0-RC2
contenir/contenir-site-token Version ^0.1
contenir/contenir-config Version ^2.1
laminas/laminas-diactoros Version ^3.0
psr/clock Version ^1.0
psr/container Version ^1.1 || ^2.0
psr/http-message Version ^1.1 || ^2.0
psr/http-server-middleware Version ^1.0
psr/simple-cache Version ^1.0 || ^2.0 || ^3.0