Using TSConfig to Ensure Dynamic Page Elements Are Always Up to Date

A common use for TypoScript (at least on my TYPO3 sites) is to dynamically generate lists and menus of other content items in the CMS, based on some set of criteria, and then insert these into a page.

For example, I might want to have a “5 most recent items posted to site section X” menu on my homepage.  With TypoScript, this is (reasonably) easy to do.

However, in some cases this can cause problems with TYPO3’s internal caching mechanism.  TYPO3 caches content aggressively to minimize the load on the database of generating lots of pages — which is exactly what it should do. But when you have pages that depend on the content of other parts of the site, you can run into problems where those pages don’t update immediately when you alter the sections they’re tied to, requiring you to empty the cache manually.

There is an easy way to avoid this, however. Just add the following command to the TSConfig of the page where you are adding the content items that are listed in your list/menu:

TCEMAIN.clearCacheCmd = <list of page-ids>

The value of this command should be a comma-separated list of all pages where your dynamic list appears. This command will automatically rebuild those pages whenever you add something to this page, which means users will always see the most up to date list.