Problem/Motivation
Quoting @effulgentsia in #2335661-23: Outbound path & route processors must specify cacheability metadata:
See also #2417793-46: Allow entity: URIs to be entered in link fields, where changes to URL aliases don't result in a cache clear of rendered entities containing formatted links. Maybe that needs its own issue, but seems highly related to this, so just noting it here for now.
Reply by @Wim Leers in #2335661-98: Outbound path & route processors must specify cacheability metadata:
This is exactly what I feared was the case. Note that when changing the URL alias of a node, the node updates a
MenuLinkContent
entity. Which means everything is updated correctly. It is only when updating URL aliases via/admin/config/search/path
, that no invalidation happens. But, to be honest, that's really a problem independent of this issue: URL aliases don't track changes and hence also not invalidations in any way. This issue is about fixing the more general problem, that sits a level higher: to make it possible for those outbound path/route processors that do have cacheability metadata, to be able to associate that cacheability with generated URLs.
So we should fix URL aliases in a separate issue.
This is that separate issue.
Proposed resolution
As written in #12:
- When rendering
- for all route params that are used to generate the link, associate the cache tags of those that implement
CacheableDependencyInterface
with the rendered link - When saving an alias in the URL alias UI
- find the route name + params associated with the source path (=== "run routing")
- get the set of cache tags from the route params
- if empty set of cache tags: invalidate
'rendered'
cache tag - if non-empty set of cache tags: invalidate those cache tags
Remaining tasks
Do it.
User interface changes
None.
API changes
None.