Exclude fast_404 paths and file extensions by default (Performance)

Created on 16 May 2023, about 1 year ago
Updated 20 December 2023, 6 months 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.

With search404
enabled, without these exclusions, Fast 404s are definitely NOT slower than regular 404s.

Proposed resolution

a) 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';

b) An alternative approach would be to recommend enabling the additions to the settings.php for such cases again.

c) Another comfortable solution might be to exclude paths ending with a non-whitelisted file extension in general?
I created a separate child issue for this, as I think that might be the best solution: πŸ“Œ Add option to exclude all non whitelisted file paths (Performance) Needs review

Remaining tasks

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

User interface changes

TBD

API changes

TBD

Data model changes

TBD

πŸ› Bug report
Status

Postponed: needs info

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.69.0 2024