‪TYPO3CMS  ‪main
TYPO3\CMS\Frontend\Cache\CacheInstruction Class Reference

Public Member Functions

 disableCache (string $reason)
 
 isCachingAllowed ()
 
 getDisabledCacheReasons ()
 

Private Attributes

bool $allowCaching = true
 
array $disabledCacheReasons = []
 

Detailed Description

This class contains cache details and is created or updated in middlewares of the Frontend rendering chain and added as Request attribute "frontend.cache.instruction".

Its main goal is to disable the Frontend cache mechanisms in various scenarios, for instance when the admin panel is used to simulate access times, or when security mechanisms like cHash evaluation do not match.

Definition at line 28 of file CacheInstruction.php.

Member Function Documentation

◆ disableCache()

TYPO3\CMS\Frontend\Cache\CacheInstruction::disableCache ( string  $reason)

Instruct the core Frontend rendering to disable Frontend caching. Extensions with custom middlewares may set this.

Note multiple cache layers are involved during Frontend rendering: For instance multiple TypoScript layers, the page cache and potentially others. Those caches are read from and written to within various middlewares. Depending on the position of a call to this method within the middleware stack, it can happen that some or all caches have already been read of written.

Extensions that use this method should keep an eye on their middleware positions in the stack to estimate the performance impact of this call. It's of course best to not use the 'disable cache' mechanic at all, but to handle caching properly in extensions.

Definition at line 47 of file CacheInstruction.php.

Referenced by TYPO3\CMS\Frontend\Middleware\PageArgumentValidator\evaluateCacheHashParameter(), TYPO3\CMS\Frontend\Middleware\PageArgumentValidator\evaluatePageArgumentsWithoutCacheHash(), and TYPO3\CMS\Frontend\Middleware\PageArgumentValidator\evaluateQueryParametersWithoutCacheHash().

◆ getDisabledCacheReasons()

TYPO3\CMS\Frontend\Cache\CacheInstruction::getDisabledCacheReasons ( )

Typically only consumed by extensions like EXT:adminpanel

Definition at line 67 of file CacheInstruction.php.

References TYPO3\CMS\Frontend\Cache\CacheInstruction\$disabledCacheReasons.

◆ isCachingAllowed()

TYPO3\CMS\Frontend\Cache\CacheInstruction::isCachingAllowed ( )

Member Data Documentation

◆ $allowCaching

bool TYPO3\CMS\Frontend\Cache\CacheInstruction::$allowCaching = true
private

◆ $disabledCacheReasons

array TYPO3\CMS\Frontend\Cache\CacheInstruction::$disabledCacheReasons = []
private