Dynamic page cache stores user token values causing invalid data

Created on 6 May 2020, over 4 years ago
Updated 6 July 2023, over 1 year ago

The Drupal dynamic page cache caches pages/responses for authenticated users. Drupal essentially stores a copy of the page for each role combination (and other factors, like language). This means if you use user tokens in custom dimensions, the token value of the first user with a particular role combination to visit an uncached page will then get re-used for every other authenticated user with that same role combination on that page, until caches are cleared.

Steps to reproduce

# Create a custom dimension with a user token that could vary by users with the same role combination. For testing purposes you can use UID though I don't think you should be tracking UID in prod.
# Log in to your site as user 123 with role A.
# Visit a page that is eligible for the Dynamic Page Cache. Such pages will have a HTTP header x-dynamic-page-cache = HIT/MISS (not UNCACHEABLE).
# Using a browser plug-in observe that the GA custom dimension is set.
# Refresh the page and observe the HTTP header x-dynamic-page-cache = HIT
# In another browser session, log in as user 768 with role A.
# Visit the same Dynamic Page Cache eligible page. Observer that the HTTP header x-dynamic-page-cache = HIT but the custom dimension value is associated with user 123, not user 768.

πŸ› Bug report
Status

Closed: outdated

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States krlucas

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡ΊπŸ‡ΈUnited States japerry KVUO

    With the sunset of legacy google analytics, the 8.x-2.x module is now unsupported. If this is still an issue with the 4.x version, please file a new issue in the queue.

Production build 0.71.5 2024