Issue Bug Closed

#96502ModifyUrlForCanonicalTagEvent Caching issue on dynamic detail pages?

Reinhard Hiebl 01/11/22, 09:35 updated 11/09/26, 15:59

Description

Hello,
i have to modify the canonical tag. I do this thru the ModifyUrlForCanonicalTagEvent.
But after cache it always keeps the canonical url from the first cached page. Maybe additionalHeaderData in general is affected.
Don’t know its a bug or i am using something wrong. The PageTitleGenerator works fine.

*services.yaml*
NS\MyExt\EventListener\CanonicalListener is called only once. Looks like route arguments below not respected in the cache hash?

services:
  ....
  NS\MyExt\EventListener\CanonicalListener:
    tags:
      - name: event.listener
        identifier: 'ns/myext/canonical'
        after: 'cs-seo/canonical'
        event: TYPO3\CMS\Seo\Event\ModifyUrlForCanonicalTagEvent

*Site config.yaml*
Looks like the my_ext_item_slug argument will not respected in the page cache hash?
This probably where the problem is. But why?
(I am using the Simple type because the data are fetched from an remote rest api)

routeEnhancers:
  MyExtItemDetail:
    type: Simple
    limitToPages:
      - 1047
    routePath: '/{my_ext_item_slug}'
    requirements:
      my_ext_item_slug: '^$|[a-zA-Z0-9-].*'
    _arguments:
      my_ext_item_slug: my_ext_item_slug

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 5

  1. Benni Mack commented and changed status New Closed <span data-processor="relativetime" data-value="2026-11-09T15:59:20+00:00" > 11/09/26, 15:59 </span>

    The page cache only varies by dynamic route arguments when a valid cHash is present. Your Simple enhancer has no aspects, so my_ext_item_slug is dynamic; if the detail URLs are called without cHash and $GLOBALS[‘TYPO3_CONF_VARS’][‘FE’][‘cacheHash’][‘enforceValidation’] is false (legacy default for upgraded installations, see Important-95297), all slugs share one cache entry — including the canonical tag. Generate the links via typolink (which adds the cHash) and set enforceValidation to true, or use a custom route aspect so the slug becomes a static route argument. Closing as this is not a bug in the canonical event.