.. include:: /Includes.rst.txt .. index:: Events; AfterCacheableContentIsGeneratedEvent .. _AfterCacheableContentIsGeneratedEvent: ===================================== AfterCacheableContentIsGeneratedEvent ===================================== .. versionadded:: 12.0 This event together with :ref:`AfterCachedPageIsPersistedEvent` has been introduced to serve as a direct replacement for the removed hooks: * :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-cached']` * :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all']` * :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['usePageCache']` The PSR-14 event :php:`\TYPO3\CMS\Frontend\Event\AfterCacheableContentIsGeneratedEvent` can be used to decide if a page should be stored in cache. It is executed right after all cacheable content is generated. It can also be used to manipulate the content before it is stored in TYPO3's page cache. In the Core, the event is used in :doc:`EXT:indexed_search ` to index cacheable content. The :php:`AfterCacheableContentIsGeneratedEvent` contains the information if a generated page is able to store in cache via the :php:`$event->isCachingEnabled()` method. This can be used to differentiate between the previous hooks `contentPostProc-cached` and `contentPostProc-all`. The later hook was called regardless of whether the cache was enabled or not. Example ======= Registration of the `AfterCacheableContentIsGeneratedEvent` in your extension's :file:`Services.yaml`: .. literalinclude:: _AfterCacheableContentIsGeneratedEvent/_Services.yaml :language: yaml :caption: EXT:my_extension/Configuration/Services.yaml Read :ref:`how to configure dependency injection in extensions `. The corresponding event listener class: .. literalinclude:: _AfterCacheableContentIsGeneratedEvent/_MyEventListener.php :language: php :caption: EXT:my_extension/Classes/Frontend/EventListener/MyEventListener.php API === .. include:: /CodeSnippets/Events/Frontend/AfterCacheableContentIsGeneratedEvent.rst.txt