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.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | 3364452-allow-40x-caching.patch | 2.81 KB | michel.g |
Issue fork cache_control_override-3364452
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
gaëlgThe patch can be found here: https://git.drupalcode.org/issue/cache_control_override-3364452/-/commit...
Comment #4
prudloff commentedI tried the patch on https://master-oowrqeonft6ldtavsemgri12jdeiaq35.tugboatqa.com/ and confirms it adds a
Cache-Control: max-age=3600, publicheader on 404 pages.I also tested locally that setting
$settings['cache_ttl_4xx']changes the duration.Comment #5
prudloff commentedComment #6
michel.g commentedGot merge conflicts with the latest dev branch so I've created a new patch (no access to alter the MR)
Comment #7
gaëlgI think you should have a "get push access" green button above, to alter the MR.