Improve X-Drupal-Cache and X-Drupal-Dynamic-Cache headers, even for responses that are not cacheable

Created on 10 March 2018, about 7 years ago
Updated 11 September 2024, 7 months ago

Problem/Motivation

Currently if a response is not cacheable Drupal sets X-Drupal-Dynamic-Cache = UNCACHEABLE, but in some cases it does not. See DynamicPageCacheSubscriber::onResponse for details.

Steps to reproduce

NA

Proposed resolution

Always set X-Drupal-Dynamic-Cache header.

  1. This changes the existing X-Drupal-Dynamic-Cache: UNCACHEABLE to X-Drupal-Dynamic-Cache: UNCACHEABLE (poor cacheability).
  2. This adds X-Drupal-Dynamic-Cache: UNCACHEABLE (no cacheability) (for responses which aren't instances of CacheableResponseInterface).
  3. This adds X-Drupal-Dynamic-Cache: UNCACHEABLE (policy) (when the Dynamic Page Cache request/response policy tagged services deny caching).

This makes it much easier for developers to understand what the Dynamic Page Cache module is doing, and why.

Remaining tasks

Review

User interface changes

NA

API changes

NA

Data model changes

Don't think so

Release notes snippet

Page Cache & Dynamic Page Cache response headers improved to include more detail about the cacheability. See change record.

๐Ÿ“Œ Task
Status

RTBC

Version

11.0 ๐Ÿ”ฅ

Component
Request processingย  โ†’

Last updated 3 days ago

No maintainer
Created by

๐Ÿ‡ท๐Ÿ‡บRussia Chi

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

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot โ†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • ๐Ÿ‡ท๐Ÿ‡ดRomania claudiu.cristea Arad ๐Ÿ‡ท๐Ÿ‡ด

    claudiu.cristea โ†’ made their first commit to this issueโ€™s fork.

  • @claudiucristea opened merge request.
  • Status changed to Needs review about 2 years ago
  • ๐Ÿ‡ท๐Ÿ‡ดRomania claudiu.cristea Arad ๐Ÿ‡ท๐Ÿ‡ด
  • ๐Ÿ‡ท๐Ÿ‡ดRomania claudiu.cristea Arad ๐Ÿ‡ท๐Ÿ‡ด

    Updated the change record to match the MR.

  • ๐Ÿ‡ท๐Ÿ‡ดRomania claudiu.cristea Arad ๐Ÿ‡ท๐Ÿ‡ด

    Narrowed from 268 to 8 failures.

  • Status changed to Needs work almost 2 years ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Moving to NW for the failures.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    This would be fantastic to ship at last! ๐Ÿคž

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Needs a new MR against 11.x. Let's finally land this โ€” we now have fantastic new tooling such as StandardPerformanceTest (thanks to ๐Ÿ“Œ Allow assertions on the number of database queries run during tests RTBC and many follow-ups) that this would be a valuable addition to, especially for real-world sites. Just today, I helped out a colleague in Acquia's Professional Services department, and it'd have been far simpler to narrow down root causes if this would've existed. ๐Ÿ“Œ Log every individual query in performance tests Needs work landed earlier today too, so I'm convinced we can do this one as well! ๐Ÿ˜Š

  • First commit to issue fork.
  • Merge request !67902951814: Rerolling to drupal 11.x branch. โ†’ (Open) created by vakulrai
  • Pipeline finished with Failed
    about 1 year ago
    Total: 188s
    #105050
  • Pipeline finished with Failed
    about 1 year ago
    Total: 185s
    #105051
  • Pipeline finished with Failed
    about 1 year ago
    Total: 483s
    #105064
  • Pipeline finished with Failed
    about 1 year ago
    Total: 514s
    #105596
  • Pipeline finished with Failed
    about 1 year ago
    Total: 548s
    #105620
  • Pipeline finished with Failed
    about 1 year ago
    Total: 708s
    #105893
  • Pipeline finished with Failed
    about 1 year ago
    Total: 475s
    #105906
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vakulrai

    I have rerolled to 11.x and have brought down the test failure to 6 :), please review the reroll and suggest path forward to fix the remaining test failures.
    Thanks !

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Believe the failures are showing that the solution needs to be relooked at.

  • Pipeline finished with Failed
    about 1 year ago
    Total: 505s
    #107764
  • Pipeline finished with Success
    about 1 year ago
    Total: 539s
    #107877
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vakulrai

    All test Passed , moving to review !

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Hiding patches and old MRs for clarity.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    smustgrave โ†’ changed the visibility of the branch 2951814-cache-header-10.1.x to hidden.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    smustgrave โ†’ changed the visibility of the branch 2951814-always-set-x-drupal-cache to hidden.

  • Status changed to RTBC about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Updated CR version

    Updated issue summary to include release notes, as I think this is a good highlight.

    Believe the reroll is correct.

  • Status changed to Needs work about 1 year ago
  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • First commit to issue fork.
  • Pipeline finished with Failed
    10 months ago
    #187260
  • Pipeline finished with Failed
    10 months ago
    Total: 618s
    #187275
  • Pipeline finished with Failed
    10 months ago
    Total: 559s
    #187293
  • Pipeline finished with Running
    10 months ago
    #187306
  • Pipeline finished with Success
    10 months ago
    Total: 521s
    #187335
  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    Back to review \o/

  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary
  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    Even if this gets merged, this other issue still remains relevant.

  • Status changed to RTBC 10 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Ran test-only feature https://git.drupalcode.org/issue/drupal-2951814/-/jobs/1740771 which shows test coverage

    CR is well written with the examples

    +1 from me

  • Status changed to Needs work 10 months ago
  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary
  • Status changed to RTBC 10 months ago
  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    Back to RTBC after rebase.

  • Pipeline finished with Failed
    10 months ago
    Total: 515s
    #198701
  • Status changed to Needs work 10 months ago
  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    Meh... ofc simple rebase wasn't enough

    Drupal\Tests\jsonapi\Functional\UserTest::testGetIndividual
    Failed asserting that false is identical to true.
    
    core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php:1030
    

    This should be also caused by the recently merged https://git.drupalcode.org/project/drupal/-/commit/9fc1bc9ac5a785ebf6e88......

  • Pipeline finished with Success
    10 months ago
    Total: 916s
    #198751
  • Status changed to Needs review 10 months ago
  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary
  • Status changed to RTBC 10 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    Rebase seems good.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    (rebased)

  • Pipeline finished with Success
    10 months ago
    Total: 539s
    #200773
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Anybody Porta Westfalica

    This will further improve and simplify cache debugging! Thank you all very much for your hard work on this. Very much looking forward to this functionality!

  • Status changed to Needs work 9 months ago
  • The Needs Review Queue Bot โ†’ tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • Status changed to RTBC 9 months ago
  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    Gitlab says MR still applies, back to RTBC.

  • Status changed to Needs work 9 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States neclimdul Houston, TX

    Checking GL, it does say "Merge conflicts must be resolved." so think this needs another rebase.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    mxr576 โ†’ changed the visibility of the branch drupal-2951814 to hidden.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    mxr576 โ†’ changed the visibility of the branch 2951814-always-set-x-drupal-cache to active.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    Indeed... :sadpanda: Rebasing again... PHPStorm could auto-resolve all :fingers-crossed:.

     git rebase origin/11.x
    Auto-merging core/modules/basic_auth/tests/src/Functional/BasicAuthTest.php
    Auto-merging core/modules/jsonapi/tests/src/Functional/NodeTest.php
    CONFLICT (content): Merge conflict in core/modules/jsonapi/tests/src/Functional/NodeTest.php
    Auto-merging core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
    CONFLICT (content): Merge conflict in core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
    Auto-merging core/modules/layout_builder/tests/src/Functional/LayoutSectionTest.php
    Auto-merging core/modules/node/tests/src/Functional/NodeBlockFunctionalTest.php
    Auto-merging core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
    error: could not apply d8f6085835... Applying https://www.drupal.org/files/issues/2021-02-24/2951814-85.patch
    hint: Resolve all conflicts manually, mark them as resolved with
    hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
    hint: You can instead skip this commit: run "git rebase --skip".
    hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
    Could not apply d8f6085835... Applying https://www.drupal.org/files/issues/2021-02-24/2951814-85.patch
    
    
  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    mxr576 โ†’ changed the visibility of the branch 2951814-always-set-x-drupal-cache to hidden.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    mxr576 โ†’ changed the visibility of the branch drupal-2951814 to active.

  • Status changed to Needs review 9 months ago
  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary
  • Pipeline finished with Success
    9 months ago
    Total: 555s
    #224050
  • Status changed to RTBC 8 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States smustgrave

    believe rebase is good.

  • First commit to issue fork.
  • Pipeline finished with Success
    8 months ago
    Total: 477s
    #251782
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia ankitv18

    Rebased the forked branch ~~ RTBC++

  • Pipeline finished with Success
    7 months ago
    Total: 543s
    #271388
  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    Rebased, there was only one conflict in a test file that PHPStorm could autoresolve easily.

    โฏ git rebase origin/11.x
    Auto-merging core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php
    Auto-merging core/modules/language/tests/src/Functional/LanguageBrowserDetectionAcceptLanguageTest.php
    Auto-merging core/modules/page_cache/tests/src/Functional/PageCacheTest.php
    CONFLICT (content): Merge conflict in core/modules/page_cache/tests/src/Functional/PageCacheTest.php
    Auto-merging core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php
    Auto-merging core/modules/rest/tests/src/Functional/ResourceTestBase.php
    Auto-merging core/modules/system/tests/src/Functional/Session/SessionTest.php
    Auto-merging core/modules/system/tests/src/Functional/System/ErrorHandlerTest.php
    Auto-merging core/modules/user/tests/src/Functional/UserPasswordResetTest.php
    
  • ๐Ÿ‡ญ๐Ÿ‡บHungary mxr576 Hungary

    May I recommend this feature to 10.4.0 release notes?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States grasmash

    This would certainly have saved me hours of debugging. Perhaps this is a bridge too far, but it would also help to identify which modules are adding which tags/contexts.

  • Pipeline finished with Failed
    6 months ago
    Total: 304s
    #292542
  • Pipeline finished with Canceled
    6 months ago
    Total: 82s
    #298945
  • Pipeline finished with Canceled
    6 months ago
    Total: 232s
    #298946
  • Pipeline finished with Failed
    6 months ago
    Total: 426s
    #298951
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Updated issue credit. Removed credit for partial rerolls and tried to credit everyone who contributed test fixing & comments that help direct the work.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Committed 19f80f6 and pushed to 11.x. Thanks!

    Let's backport this to 10.4.x

  • Merge request !9736Backport of 2951814 โ†’ (Open) created by alexpott
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ

    Created the backport MR - I wanted a full test run. There were no merge conflicts so I'm going to set to RTBC in the hope it is green. If it is, I will cherry-pick the 11.x commit to 10.4.x

  • Pipeline finished with Success
    6 months ago
    Total: 868s
    #299293
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom alexpott ๐Ÿ‡ช๐Ÿ‡บ๐ŸŒ
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024