Feature: #96879 - New PSR-14 Event ModifyCacheLifetimeForPageEvent

See Issue #96879

Description

A new PSR-14 Event ModifyCacheLifetimeForPageEvent has been introduced. This event serves as a successor for the $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['get_cache_timeout'] hook.

Impact

The new Event allows to modify the lifetime how long a rendered page of a frontend call should be stored in the “pages” cache.

Common registration and usage for a listener:

services:
  MyCompany\MyPackage\EventListener\ChangeCacheTimeout:
    tags:
      - name: event.listener
        identifier: 'mycompany/mypackage/cache-timeout'
<?php

namespace MyCompany\MyPackage\EventListener;

class ChangeCacheTimeout
{
    public function __invoke(ModifyCacheLifetimeForPageEvent $event): void
    {
        // Only cache all pages for 30 seconds when in development context
        if (Environment::getContext()->isDevelopment()) {
            $event->setCacheLifetime(30);
        }
    }
}