Allow configuring to *never* store in Page Cache when using Sessionless BigPipe

Created on 23 October 2023, about 1 year ago

Problem/Motivation

Per 💬 Using Sessionless BigPipe to ALWAYS serve using BigPipe and NEVER from PageCache when using BigPipe Paragraphs (or other functionality) Fixed , some sites may want to opt in to never have their placeholdered BigPipe Paragraphs served via BigPipe Sessionless, but instead may want it to be always served to anonymous (aka sessionless) users using BigPipe instead.

I re-read @jefuri's excellent comments and now articulated how you can achieve that:

  1. Eventually, Sessionless BigPipe calls \Drupal\big_pipe_sessionless\Render\BigPipeSessionless::primePageCache() with a HtmlResponse object to prime the Page Cache with.
  2. That calls \Drupal\page_cache\StackMiddleware\PageCache::storeResponse(), which contains this logic:
        // Allow policy rules to further restrict which responses to cache.
        if ($this->responsePolicy->check($response, $request) === ResponsePolicyInterface::DENY) {
          return FALSE;
        }
    
  3. In other words: the Page Cache will not be primed if BigPipe Paragraphs were to define a response policy that detects whether the response contains rendered BigPipe Paragraphs placeholders … which would give you exactly the behavior you're asking for 😊

#3220570-8: Using Sessionless BigPipe to ALWAYS serve using BigPipe and NEVER from PageCache when using BigPipe Paragraphs (or other functionality)

Steps to reproduce

N/A

Proposed resolution

  1. Implement a PageCache \Drupal\Core\PageCache\ResponsePolicyInterface service.
  2. Allow sites to opt in to this using configuration.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

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

Comments & Activities

Production build 0.71.5 2024