"non admin routes" cache fragmentation

Created on 28 March 2020, over 4 years ago
Updated 11 February 2023, over 1 year ago

The Drupal\Core\Routing\RoutePreloader is subscribed for the kernel.request event with default weight (0), but there are modules (for example redirect ) which have subscribers with higher weight (https://git.drupalcode.org/project/redirect/-/blob/8.x-1.x/src/EventSubs...).

If such subscribers load single route before RoutePreloader then it makes the "non admin routes" cache fragmented, because the Drupal\Core\Routing\RouteProvider removes already loaded routes from the $routes_to_load. As the result the hash value is different on different pages (hash value is used to build cid): https://git.drupalcode.org/project/drupal/-/blob/8.8.x/core/lib/Drupal/C...

Steps to reproduce

1. Install a fresh core using "standard" profile
2. Install a redirect module
3. Create a node of any type
4. Create a taxonomy term of any type
5. Open a created node and check "cache_data" table. You will see one cache item with all non admin routes + separate record for entity.node.canonical route
6. Open a created taxonomy term and check "cache_data" table. You will see one more cache item with all non admin routes + separate record for entity.taxonomy_term.canonical
7. Open a user page and check "cache_data" table. You will see one more cache item with all non admin routes + separate record for entity.user.canonical

Expected result

One "non admin routes" cache item is created and used for any page + there are no records for single route (see screenshot1 ) (it's default behaviour when installed fresh core without any modules).

Actual result

Multiple "non admin routes" cache items are created + there are records for single route (see screenshot2 )

Proposed resolution

Change weight of Drupal\Core\Routing\RoutePreloader subscriber to 999.

🐛 Bug report
Status

Closed: duplicate

Version

9.5

Component
Routing 

Last updated about 11 hours ago

Created by

🇧🇾Belarus zestagio

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024