Do not prevent caching of 403/404

Created on 2 June 2023, over 1 year ago
Updated 2 September 2024, 2 months ago

Problem/Motivation

Most of the time, 403/404 pages have a zero Drupal cache max-age (see https://www.drupal.org/node/2920529 ).
Still, Drupal has a setting named cache_ttl_4xx (defaults to 1 hour) which tells how much time a 403/404 page should stay in Drupal cache (even if Drupal cache max-age is zero).
This module should probably not prevent that behavior, or many 403/404 will remain uncacheable, which is bad for server performance/energy consumption (and many bad bots use to ask for pages that do not exist, looking for security holes).
Furthermore, for even better performance, it would be nice that those pages can remain not only in Drupal cache but also in a reverse-proxy cache (such as Varnish) if there's one.
If you use this module but do not want to cache those error pages, you should simply set cache_ttl_4xx to zero.

Steps to reproduce

Enable the module, ensure your cache_ttl_4xx setting is not zero, go to a non-existing URL (anonymously), you will still get "max-age=0" in the Cache-Control header of the response.

Proposed resolution

Patch coming.

Remaining tasks

Review coming patch.

User interface changes

None.

API changes

None.

Data model changes

None.

Feature request
Status

RTBC

Version

2.0

Component

Code

Created by

🇫🇷France GaëlG Lille, France

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024