Aswin Lutchanah

Hybrid Social Media Specialist + Php/MySql Developer Metz (Développeur Php/MySql Metz) + SEO-SMO

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:

  1. $oTce = t3lib_div::makeInstance(‘t3lib_TCEmain’);
  2. $oTce->start(array(), array());
  3. $oTce->clear_cacheCmd($iUid);

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
  1. $oTce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(‘t3lib_TCEmain’);
  2. $oTce->start(array(), array());
  3. $oTce->clear_cache(‘pages’, $iUid);

Hope that this helps.

Posted In: PHP, TYPO3, Web Development

Tags: , ,

2 Comments

Leave a Reply

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

*