Adding url.path to breadcrumb cache context results in every 404 page getting a different dynamic page cache entry

Created on 29 March 2025, 5 days ago

Problem/Motivation

If you install this module and visit different 404 pages you will get a dynamic page cache entry page per 404.

Steps to reproduce

  • Install Drupal CMS (no specific recipes needed)
  • Visit pages that would result in 404
  • Watch rows grow in cache_dynamic_page_cache

Proposed resolution

Not sure. Core's path based breadcrumb builder uses

    // Add the url.path.parent cache context. This code ignores the last path
    // part so the result only depends on the path parents.
    $breadcrumb->addCacheContexts(['url.path.parent', 'url.path.is_front']);

But given in default configuration to add the current page title to breadcrumb I don't think that is would work.

Also you can't add a reponse status cache to breadcromb block because that also adds a url.path to cache context. There might be a core issue here for how url.path works with 404s and 403s.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom alexpott πŸ‡ͺπŸ‡ΊπŸŒ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024