Feature: #96968 - PSR-14 Event for avoid loading Frontend pages from cache

See Issue #96968

Description

A new PSR-14 event ShouldUseCachedPageDataIfAvailableEvent is added which allows TYPO3 Extensions to register Event Listeners to modify if a page should be read from cache (if it has been created in store already), or if it should be re-built completely ignoring the cache entry for the request.

Impact

The new PSR-14 event can be used for avoiding loading from cache when indexing via CLI happens from an external source, or if the cache should be ignored when logged in from a certain IP address.

Registration of the Event in your extensions’ Services.yaml:

MyVendor\MyPackage\MyEventListener:
  tags:
    - name: event.listener
      identifier: 'my-package/avoid-cache-loading'

The corresponding event listener class:

use TYPO3\CMS\Frontend\Event\ShouldUseCachedPageDataIfAvailableEvent;

class MyEventListener {

    public function __invoke(ShouldUseCachedPageDataIfAvailableEvent $event): void
    {
        if (!($event->getRequest()->getServerParams()['X-SolR-API'] ?? null)) {
            return;
        }
        $event->setShouldUseCachedPageData(false);
    }
}