Few 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.
— Aswin Lutchanah (@aswinlutchanah) August 9, 2013
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’);
New Method – clear_cache($sTableName, $iUid)
In TYPO3 version 6, we do it differently with the clear_cache() function which has two parameters:
- the first one is the name of the table (here it is pages) – type string
- 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->clear_cache(‘pages’, $iUid);
Hope that this helps.