本文介绍了TYPO3:有哪些不同类型的缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在TYPO3后端,我可以清除不同种类的缓存:前端缓存、一般缓存、系统缓存……此外,安装工具中也有清除缓存的选项.

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.

在许多情况下,尤其是在我开发扩展时,我需要清除缓存以反映我所做的更改.但是,我从来不知道我需要清除哪些缓存,而且大多数情况下,我会清除每个缓存,直到在重新加载页面时看到正确的输出.在其他情况下,例如升级TYPO3时,我需要从安装工具中清除缓存,否则它会在旧安装路径中查找php文件.

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)?

推荐答案

在 TYPO3 6.2 和 7 中:

In TYPO3 6.2 and 7:

您可以在SYS.caching.cacheConfiguration部分的后端系统>配置中看到所有缓存的配置.每个缓存都注册在一个或多个组"中:所有、系统、页面.菜单项反映了这些组:

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:

  • 刷新前端缓存"(cacheCmd=pages):清除前端和页面相关的缓存.这使得 TYPO3 重新渲染通常缓存的内容(除 USER_INT 对象之外的所有内容)
  • 刷新通用缓存"(cacheCmd=all):包括前端,加上一些由clearAllCache_additionalTables 的扩展注册的缓存(即新闻缓存、realurl 缓存).尽管是all,但它包括系统缓存(这就是为什么它在菜单中被称为通用缓存"而不是所有缓存").
  • 刷新系统缓存"(cacheCmd=system):清除系统相关缓存",包括类加载器、本地化和扩展配置文件缓存.
  • 安装工具清除所有缓存":这是删除所有typo3temp/var/Cache 文件"以及所有MySQL 缓存表(cf_*",即Extbase 反射)的硬连线.然后它会遍历所有注册的缓存并清除它们.
  • "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:

  • Extbase 中的 PHP 类在所谓的反射缓存"(即注释)中解析其内容 => 刷新系统缓存.
  • 您的扩展设置ext_tables.phpext_localconf.phpTCA 缓存在cache_core => 刷新系统缓存.
  • 您的流体模板被编译成 PHP 代码 => 刷新系统缓存.
  • 您的 PHP 代码可能会被 PHP 的opcache"缓存.通常 opcaches 被配置为检查文件的修改时间,所以通常你不需要在修改 PHP 文件后刷新任何 opcache.在某些情况下可能不是这种情况,或者如果您在系统时间的符号链接中工作不同步,那么您可能需要在 PHP 代码更改后刷新 opcache => 安装工具清除所有缓存.
  • 您的 TypoScript 也被缓存 (cache_hash) => 刷新前端缓存.请注意,如果您更改后备文件中的 TypoScript,这将自动刷新这些缓存.
  • 如果您的更改也会影响呈现到前端的缓存输出,您可能还需要刷新前端缓存.为避免这种情况,您可以在 TypoScript 中设置:config.no_cache = 1.
  • 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.

请注意,从TYPO3 8.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:

  • 刷新前端缓存":像以前一样清除前端和页面相关的缓存.
  • 刷新所有缓存":或多或少地执行安装工具以前所做的工作.因此,这也将包括所有扩展缓存、反射、系统缓存.由于它包含opcache 刷新",因此 PHP 文件更改也会反映在此处.

为了在不关心其中一些缓存的情况下简化开发,您可能需要单独关闭"它们.

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;

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

这篇关于TYPO3:有哪些不同类型的缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 13:22