I need to flush a cache for a specific page from TYPO3 version 8 backend in the Extension from my Controller. I found a solution for flushing all caches but this is the last option.
How to flush or update cache for page by id in TYPO3
GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class)
->flushCachesInGroupByTags('pages', [ 'pageId_'.$id ]);
The core handles the page cache clear using the DataHandler;
See: \TYPO3\CMS\Recordlist\RecordList::clearCache
/**
* Clears page cache for the given page id, $this->id
*/
public function clearCache(int $pageId)
{
$tce = GeneralUtility::makeInstance(DataHandler::class);
$tce->start([], []);
$tce->clear_cacheCmd($pageId);
}
Thanks, I will try too. What is the difference between this two solutions? –
Wallraff
The other solution uses the internal logic from the
DataHandler
(tag naming scheme). The DataHandler
internally uses the CacheManager
too. –
Faultless From within controller context (as asked..)
$this->cacheService->clearPageCache([$pageIds]);
This call includes the marked answer above.
Sorry i cannot comment directly to the answer from Benjamin. The second solution with DataHandler only works in backend context. If you want to clear the cache from your frontend plugin, you must use the marked answer.
© 2022 - 2024 — McMap. All rights reserved.