Cache clearing

Clearing the cache after changing news records

News has a built-in mechanism that takes care of clearing the cache after manipulation of News records.

When a list or detail view is rendered on a page, a cache tag in format tx_news_pid_PID (where PID is the uid of the news storage folder) is added. Each time a news record is edited, deleted or created, this cache entry is flushed. No additional cache configuration is needed if only the News plugins are used.

If you use other ways of displaying news records (e.g. an RSS feed created by TypoScript on a page without a News plugin), the cache is not flushed automatically.

This can be done automatically by using this command in the PageTsConfig: :

page TSconfig
TCEMAIN.clearCacheCmd = 123,456,789
Copied!

The code needs to be added to the sys folder where the news records are edited. Change the example page ids to the ones which should be cleared, e.g. a page with an RSS feed. You can use:

page TSconfig
TCEMAIN.clearCacheCmd = pages
Copied!

to clear the complete caches as well:

page TSconfig
TCEMAIN.clearCacheCmd = cacheTag:tx_news
Copied!

to clear all caches of pages on which the news plugins are used but beware of performance issues when news records are edited often.

Cache lifetime and auto publishing (by setting start date)

By default the cache of TYPO3 pages is invalidated every 24 hours. If you set a specific date and time for the news record to be published in the tab Access:

This news should be published at a certain date, 12:00

The news will be published next time the cache is deleted which is usual after midnight.

When you are using the Publish Date field you can use the following TypoScript setup configuration: config.cache

Let us assume you have a news plugin on page 42 and store your news records in a sysfolder with the uid 27 then the following setting will take the publish date of your news records into account when calculating the time when the cache should expire:

EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
config.cache.42 = tx_news_domain_model_news:27
Copied!

If there is more then one page containing a news plugin that might display the news you have to make a setting for each page:

EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
config.cache {
   42 = tx_news_domain_model_news:27
   43 = tx_news_domain_model_news:27
   365 = tx_news_domain_model_news:27
}
Copied!

If you use a news plugin on every page it is also possible to define the cache clearing for all pages:

EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
config.cache.all = tx_news_domain_model_news:27
Copied!

You can also define serveral tables for one page, for example to include categories:

EXT:my_sitepackage/Configuration/TypoScript/setup.typoscript
config.cache.42 = tx_news_domain_model_news:27,sys_category:26
Copied!