Exclude fast_404 paths and file extensions by default (Performance)

Created on 16 May 2023, over 1 year ago

Problem/Motivation

With https://www.drupal.org/node/3293205 β†’ committed, it's no more recommended to set the fast_404 in settings.php so search404 will then handle all of them without this change, which will be quite performance-heavy!
See these changes: https://git.drupalcode.org/project/drupal/-/commit/10c3646

For that heavy performance impact, I'm categorizing this as bug.

Steps to reproduce

Make a call to a non-existing / no more existing file, for example .css, .js, .json, .map etc. which is never really relevant for a 404 search. Still it will trigger a 404 search for such a file, which results in expensive database queries, unclear results for the user and watchdog-logged 404's.

Typically you'd only want that for non-file paths.

Proposed resolution

Add all relevant file types / paths that were in core's fast_404 before to the exclusion on search404 or find a better alternative, like a file-type based checklist?

These (regex) are the ones that should be excluded at least:

$config['system.performance']['fast_404']['exclude_paths'] = '/\/(?:styles)|(?:system\/files)\//';
$config['system.performance']['fast_404']['paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp|svg|webp|eot|ttf|woff?2|json|html|scss|md|map)$/i';

Remaining tasks

  1. Discuss
  2. Implement
  3. Test
  4. Release

User interface changes

TBD

API changes

TBD

Data model changes

TBD

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

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

Comments & Activities

Production build 0.71.5 2024