Charles Brunet
Charles Brunet

Reputation: 23110

TYPO3: what are the different kind of caches?

In the TYPO3 backend, I can clear different kinds of cache: frontend caches, general caches, system caches... Furthermore, there are also options to clear caches in the install tools.

In many cases, especially when I develop an extension, I need to clear the caches to reflect the changes I made. However, I never really know which caches I need to clear, and most of the time, I clear each one until I saw the right output when reloading the page. In other cases, when I upgrade TYPO3 for instance, I need to clear the caches from the Install tools, otherwise it looks for php files in the old installation path.

What are the different kind of caches that can be cleared? What is the difference between each of them? Which files or database items each command clears? In which case each clear caches command is necessary (i.e. when modifying which kind of file or information)?

Upvotes: 1

Views: 1985

Answers (3)

Ernesto Baschny
Ernesto Baschny

Reputation: 456

In TYPO3 6.2 and 7:

You can see the configuration of all caches in the backend System > Configuration in the SYS.caching.cacheConfiguration section. Every cache is registered in one or more "groups": all, system, pages. The menu items reflect these groups:

  • "Flush frontend caches" (cacheCmd=pages): Clears frontend and page-related caches. This makes TYPO3 re-render content which is usually cached (everything except USER_INT objects)
  • "Flush general caches" (cacheCmd=all): Includes frontend, plus some caches registered by extensions with clearAllCache_additionalTables (i.e. news cache, realurl caches). Despite being all it does not include the system caches (and this is why it is called "general caches" and not "all caches" in the menu).
  • "Flush system caches" (cacheCmd=system): Clears "system-related caches", including the class loader, localization and extension configuration file caches.
  • Install tool "Clear all caches": This is a hardwired to "remove all typo3temp/var/Cache files", and also all MySQL cache-tables ("cf_*", i.e. Extbase Reflection). Then it goes through all registered Caches and clears them all too.

So best is to get yourself aware what parts of your code are stored in which cache so that you understand what to flush when you change something:

  • PHP classes in Extbase have their content parsed in so called "Reflection Cache" (i.e. the annotations) => Flush system cache.
  • You extension settings ext_tables.php, ext_localconf.php, TCA are cached in the cache_core => Flush system cache.
  • Your fluid templates are compiled into PHP code => Flush system cache.
  • Your PHP code might be cached by the "opcache" of your PHP. Usually opcaches are configured to check for the modification time of the file, so usually you don't need to flush any opcache after modifying PHP files. This might not be the case in some scenarios, or if there you work through symlinks of the system time is not synchronized, then you might need to flush opcache after PHP code change => Install tool clear all cache.
  • Your TypoScript is also cached (cache_hash) => Flush frontend caches. Note that if you change TypoScript in the backed, this will automatically flush these caches automatically.
  • If your change will also affect the cached output that is rendered to the frontend, you might also need to Flush frontend cache. To avoid this you might set in your TypoScript: config.no_cache = 1.

Please note that since TYPO3 8.1 the menu in the backend and the whole system has been simplified, so we only have left:

  • "Flush frontend caches": Clears frontend and page-related caches, like before.
  • "Flush all caches": Does more or less what the install tool previously did. This will thus include also all extension caches, reflection, system caches. Since it includes the "opcache flushing", also PHP file changes would be reflected here.

To ease development without caring about some of these caches, you might want to turn them individually "off".

$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['cache_pages']['backend'] = NullBackend::class;
$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['cache_pagesection']['backend'] = NullBackend::class;
$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['cache_hash']['backend'] = NullBackend::class;
$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['extbase_object']['backend'] = NullBackend::class;
$TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['extbase_reflection']['backend'] = NullBackend::class;

See: https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/CachingFramework/Configuration/Index.html?highlight=cache#how-to-disable-specific-caches

Upvotes: 9

Bernd Wilke πφ
Bernd Wilke πφ

Reputation: 10791

as noone mentioned the files yet: there are a lot of temporary files which could be removed anytime, and must be removed sometimes. partially they even are included in the cache clearing from the BE.

the base folder is /typo3temp/

caching is done in /typo3temp/Cache/ which is divided in /typo3temp/Cache/Code/ and /typo3temp/Cache/Data/

here are gathered the concatenation of some php-files (e.g. ext_tables.php)

since 7LTS there is another folder which needs manual deletion sometimes: typo3temp/autoload/ where class-information is stored for autoloading. Especially if you develop new extensions this folder is not cleared automatically on each edit.

Upvotes: 0

biesior
biesior

Reputation: 55798

In very general you need to clear frontend and general caches when changes made in the record (by editing) aren't reflected on page (because page is cached).

system cache additionally keeps different configurations from extensions (all these stuff from ext_tables.php, ext_localconf.php, language files, etc.) so you need to clear it when doing changes in these files... but also when injecting for an example new repository to the controllers.

TIP: there's some plugins for the browsers which displays cache clearing icon (a.k.a. Yellow Flash) in the address bar, i.e.: TYPO3 Clear Cache for Chrome

Upvotes: 1

Related Questions