AfterCachedPageIsPersistedEvent

New in version 12.0

This event together with AfterCacheableContentIsGeneratedEvent has been introduced to serve as a direct replacement for the removed hook:

  • $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['insertPageIncache']

The PSR-14 event \TYPO3\CMS\Frontend\Event\AfterCachedPageIsPersistedEvent is commonly used to generate a static file cache. This event is only called if the page was actually stored in TYPO3's page cache.

Example

Registration of the AfterCachedPageIsPersistedEvent in your extension's Services.yaml:

EXT:my_extension/Configuration/Services.yaml
services:
  # Place here the default dependency injection configuration

  MyVendor\MyExtension\Frontend\EventListener\MyEventListener:
    tags:
      - name: event.listener
        identifier: 'my-extension/content-modifier'
Copied!

Read how to configure dependency injection in extensions.

The corresponding event listener class:

EXT:my_extension/Classes/Frontend/EventListener/MyEventListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Frontend\EventListener;

use TYPO3\CMS\Frontend\Event\AfterCachedPageIsPersistedEvent;

final class MyEventListener
{
    public function __invoke(AfterCachedPageIsPersistedEvent $event): void
    {
        // generate static file cache
    }
}
Copied!

API

class \TYPO3\CMS\Frontend\Event\ AfterCachedPageIsPersistedEvent

Event that is used directly after all cached content is stored in the page cache.

If a page is called from the cache, this event is NOT fired. This event is also NOT FIRED when $TSFE->no_cache (or manipulated via AfterCacheableContentIsGeneratedEvent) is set.

getRequest ( )
returntype

Psr\Http\Message\ServerRequestInterface

getController ( )
returntype

TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController

getCacheIdentifier ( )
returntype

string

getCacheData ( )
returntype

array

getCacheLifetime ( )

The amount of seconds until the cache entry is invalid.

returntype

int