Search by

infrangible / m2-page-cache-vary-fix

infrangible

Fixes the built-in full page cache of Magento 2.4.8, which shows logged-in customers the cached pages of guests, for example with "Create an Account" or guest prices.

Package info

github.com/infrangible-dev/m2-page-cache-vary-fix

Homepage

Type:magento2-module

pkg:composer/infrangible/m2-page-cache-vary-fix

Statistics

Installs: 0

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

1.0.0 2026-11-27 15:41 UTC

This package is auto-updated.

Last update: 2026-11-27 15:46:29 UTC


README

Fixes a bug of the built-in full page cache of Magento 2.4.8: after logging in, customers get the cached pages of guests, for example with the links "Sign In" and "Create an Account" in the header or with the prices of guests instead of the prices of their customer group. Only the customer account pages, which are not cached, show them as logged in.

The bug

Magento keeps one cached version of a page per context, for example for guests and for each customer group. The context of a request is in the cookie X-Magento-Vary, which Magento sets when a customer logs in. Magento 2.4.8 looks for cached pages with the identifier that it saves them with, and that identifier takes the context of the request itself, which is not known yet when the cache is read. So every logged-in customer gets the version of guests. The cause is the preference for Magento\Framework\App\PageCache\IdentifierInterface in the module Magento_PageCache, reported as magento/magento2#40474.

The module gives the page cache an identifier for reading that is the same as the one for saving, but takes the context from the cookie, as Magento did before 2.4.8 and does again since 2.4.9. Saving is unchanged, so the cache keeps working for guests and gets its own versions for logged-in customers.

Only the built-in full page cache is affected: Varnish and Fastly use the cookie themselves.

Requirements

  • Magento Open Source or Adobe Commerce 2.4.8, including its patch releases (2.4.8-p1 and newer). Magento 2.4.9 has the fix itself, and Magento before 2.4.8 does not have the bug; the module cannot be installed there.
  • PHP 8.1 or newer

Installation

composer require infrangible/m2-page-cache-vary-fix
bin/magento module:enable Infrangible_PageCacheVaryFix
bin/magento setup:upgrade
bin/magento cache:flush full_page

In production mode, also run bin/magento setup:di:compile. When upgrading to Magento 2.4.9, remove the module with composer remove infrangible/m2-page-cache-vary-fix.

License

Infrangible Page Cache Vary Fix is licensed under the MIT License - see the LICENSE file for details.