Implement the "Cache HTTP Response Header" draft

Created on 30 March 2019, about 5 years ago
Updated 30 January 2023, over 1 year ago

Problem/Motivation

Drupal introduced a simple built-in reverse proxy for anonymous users many years ago. It called this "Internal Page Cache", or "Page Cache" module for short. To communicate what it's done for a given response, it uses the X-Drupal-Cache response header.

For Drupal 8, #2429617: Make D8 2x as fast: Dynamic Page Cache: context-dependent page caching (for *all* users!) β†’ added a more advanced variant: one that is aware of variants for users with different roles, but is also smart enough to exclude per-user or per-session parts of the page (and let those be rendered later). We called this the "Dynamic Page Cache" module. To follow the pre-existing module's lead, it went with X-Drupal-Dynamic-Cache.

Those are the two built-in reverse proxies. They already can make a big difference in performance and scalability. But if you add an external reverse proxy such as Varnish or even a geographically distributed one (a CDN), it becomes even more interesting.

It also becomes more difficult to understand what the chain of reverse proxies (HTTP caches) is that affected the response. Especially if a stale response was served by one of them, and the next one in the chain then also caches it for a period of time, this can become tricky to debug.

Wouldn't it be great if there were a standardized way to communicate this?

Proposed resolution

That's what https://httpwg.org/http-extensions/draft-ietf-httpbis-cache-header.html proposes πŸ₯³

It's currently a draft spec that's being proposed as a future standard. That means that now is the time to attempt to implement this and provide feedback. It proposes a Cache response header to which HTTP caches can append additional information, hence allowing the end user to analyze and the developer to debug potential caching problems (or of course just verify that it's all working as intended).

It defines precise semantics for possible "cache actions". We've been using HIT and MISS for X-Drupal-Cache. We've been using HIT, MISS and UNCACHEABLE for X-Drupal-Dynamic-Cache.

In πŸ“Œ Improve X-Drupal-Cache and X-Drupal-Dynamic-Cache headers, even for responses that are not cacheable Needs work , we've already been working the usefulness of those two Drupal response headers, to provide more specific information why a particular response was not cached. This is of course related to that.

Remaining tasks

TBD

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

TBD

✨ Feature request
Status

Needs work

Version

10.1 ✨

Component
Request processingΒ  β†’

Last updated about 10 hours ago

No maintainer
Created by

πŸ‡§πŸ‡ͺBelgium Wim Leers Ghent πŸ‡§πŸ‡ͺπŸ‡ͺπŸ‡Ί

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs change record

    A change record needs to be drafted before an issue is committed. Note: Change records used to be called change notifications.

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.

  • 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.

Production build 0.69.0 2024