Uncacheable response when using anonymous workspace negotiator

Created on 28 February 2025, 8 days ago

Problem/Motivation

An anonymous request with a Workspace activated by a cookie negotiator results in an uncacheable response.

Steps to reproduce

1. Install Drupal 11
2. Enable Workspaces and workspaces_ui
3. Enable this module https://git.drupalcode.org/sandbox/devin-3509741
4. Grant "view any workspace" to Anonymous users
5. Create a page in the live workspace
6. Edit the page in the stage workspace
7. Make requests:

curl -H "Cookie: devin=yes" -k https://drupal11.lndo.site/node/1 -o /dev/null -vvv

This returns: < x-drupal-dynamic-cache: UNCACHEABLE (poor cacheability)

curl -k https://drupal11.lndo.site/node/1 -o /dev/null -vvv

This returns: < x-drupal-dynamic-cache: HIT

Proposed resolution

In \Drupal\workspaces\EntityAccess:

The cachePerUser() in bypassAccessResult() is the issue, removing it allows the response to be cached correctly.

Not sure what the proper solution is but removing that allowed anonymous requests to be cached and activate the correct workspace based on a cookie.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.1 πŸ”₯

Component

workspaces.module

Created by

πŸ‡ΊπŸ‡ΈUnited States djdevin Philadelphia

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

Comments & Activities

Production build 0.71.5 2024