Feature: #102628 - Cache instruction middleware
See forge#102628
Description
TYPO3 v13 introduces the new frontend-related PSR-7 request attribute
frontend.
implemented by class
\TYPO3\
. This replaces the
previous
Typoscript
property and boolean
no
request
attribute.
Impact
The attribute can be used by middlewares to disable cache mechanics of the frontend rendering.
In early middlewares before
typo3/
, the attribute may or may not exist
already. A safe way to interact with it is like this:
$cacheInstruction = $request->getAttribute('frontend.cache.instruction', new CacheInstruction());
$cacheInstruction->disableCache('EXT:my-extension: My-reason disables caches.');
$request = $request->withAttribute('frontend.cache.instruction', $cacheInstruction);
Extension with middlewares or other code after
typo3/
can assume the attribute to
be set already. Usage example:
$cacheInstruction = $request->getAttribute('frontend.cache.instruction');
$cacheInstruction->disableCache('EXT:my-extension: My-reason disables caches.');