Aswin Lutchanah

Hybrid Social Media Manager

Clear cache of a single page in TYPO3 V6

TYPO3 logoFew days back, I was looking for a way to clear the cache of a single page in TYPO3 version 6 with PHP. Desperate, I even tweeted about it expecting some clues but in vain… Finally, I got the answer while diving in the source code of TYPO3. The objective of this article is to provide an answer to my own tweet and thus avoiding you the pain. And yes, it will also act as a reminder for me.

Old Method –¬†clear_cacheCmd($iUid)

Previously, to clear the cache of a page in TYPO3, we did it by passing the uid to the clear_cacheCmd() function as follows:

$oTce = t3lib_div::makeInstance('t3lib_TCEmain');
$oTce->start(array(), array());

New Method – clear_cache($sTableName, $iUid)

In TYPO3 version 6, we do it differently with the clear_cache() function which has two parameters:

  1. the first one is the name of the table (here it is pages) – type string
  2. the second one is the uid of the page for which we want to clear the cache – type integer
$oTce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_TCEmain');
$oTce->start(array(), array());
$oTce->clear_cache('pages', $iUid);

Hope that this helps.

Posted In: PHP, TYPO3, Web Development

Tags: , ,


Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.