Support an independent max-age for 4xx responses

Created on 16 April 2015, over 9 years ago
Updated 26 January 2024, 10 months ago

Problem/Motivation

As part of the system.performance config, Drupal currently includes the cache.page.max_age property that provides the max-age value in Cache-Control header on cacheable responses. There are many scenarios where it is desirable to have an independent max-age for 4xx responses.

Proposed resolution

In addition to invalidating the Drupal cache ( #2472281: 404/403 responses for non-existing nodes are cached in Page Cache/reverse proxy, are not invalidated when the node is created β†’ ), make the emitted max-age for 4xx responses independent of the standard max-age.

This new property should still be part of the system.performance and named cache.page.4xx_max_age and be nullable. The value of this new property should be set to null initially and fallback to the standard cache.page.max_age if not set.

Remaining tasks

User interface changes

No changes (per discussion in comments below).

API changes

New config to provide the max-age value in Cache-Control header on 4xx responses.

Discovered by pwolanin & klausi.

πŸ“Œ Task
Status

Needs work

Version

11.0 πŸ”₯

Component
Request processingΒ  β†’

Last updated 2 days ago

No maintainer
Created by

πŸ‡ΊπŸ‡ΈUnited States pwolanin

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave
         $is_cacheable = ($this->requestPolicy->check($request) === RequestPolicyInterface::ALLOW) && ($this->responsePolicy->check($response, $request) !== ResponsePolicyInterface::DENY);
    +
         $client_err

    1. Seems out of scope

         $max_age = $response->isClientError() && isset($client_error_max_age)
           ? $client_error_max_age
             : $this->config->get('cache.page.max_age');
    +
         // Add headers 

    2. Same

    3. 3 more instances of spacing being added which is out of scope

    and patch #129 is removing test coverage.

  • πŸ‡­πŸ‡ΊHungary szato

    Using patch #124 on D 10.1.8 fixed my issue.

    @smustgrave regarding extra lines in interdiff 124-128 (point 1., 2.) - an empty line was removed in 124, so these are OK in #128 I think.
    Point 3. and test coverage should be fixed.

  • Issue was unassigned.
  • πŸ‡­πŸ‡ΊHungary szato

    I think the assignment is not relevant after more than 1 year.

  • πŸ‡ΊπŸ‡ΈUnited States abonfatti
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Environment: PHP 7.4 & MySQL 5.7 updated deps
    last update 10 months ago
    Patch Failed to Apply
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Environment: PHP 8.1 & MySQL 5.7 updated deps
    last update 10 months ago
    Patch Failed to Apply
Production build 0.71.5 2024