Do not set anonymous session to avoid lost cacheability on redirection

Created on 4 March 2024, 9 months ago
Updated 7 March 2024, 9 months ago

Problem/Motivation

When a Drupal message is set, Drupal creates an anonymous session to show the message on the page, the result is a different page uncached. Because large sites could have a lot of access denied due to unpublished nodes or not accessible content, this must be avoided.

Steps to reproduce

  • Try to access as an anonymous user to unpublished content with the Develop web-browser tools opened
  • Review the headers of the redirection and the cacheability of the page

Anonymous cookie session on the Network tab:

Proposed resolution

To avoid generating a different page when showing a message, a solution could be to use a flag in the URL, if the flag is present, then show the Drupal message using javascript.
Example:
/user/login?destination=hola-mundo#access-denied

✨ Feature request
Status

RTBC

Version

2.2

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain eduardo morales alberti Spain, πŸ‡ͺπŸ‡Ί

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024