Preconditions and environment
- Magento 2.4.8‑p3
- Magento is running in production mode with full page cache (built-in FPC) enabled.
Steps to reproduce
- Configure a customer group to have a customer-group price for a product, then browse the product page as guest.
- Try to login as the user with the special customer group price and go back to the same page.
- Observe the rendered price before and after login with FPC enabled (log in via the standard Magento login and rely
on FPC hits after the login redirect).
Expected result
The PDP/PLP prices should immediately switch to the logged-in customer group price after login, because FPC should vary by X-Magento-Vary and Magento\Framework\App\PageCache\Identifier should be used for cache lookup.
Actual result
PDP/PLP continue to show the guest price until the product is added to the cart (the customer group price only appears on the cart). Investigation shows
Magento\Framework\App\PageCache\IdentifierInterface preference points to
Magento\PageCache\Model\App\Request\Http\IdentifierForSave
(which relies on HttpContext and is empty when FPC hits), so the wrong cache key is used and the vary cookie isn’t read, causing cached guest prices to be served to logged-in users.
Additional information
We solved it by injecting the correct preference here in module-page-cache
Index: etc/di.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/etc/di.xml b/etc/di.xml
--- a/etc/di.xml
+++ b/etc/di.xml (date 1769703123582)
@@ -44,5 +44,5 @@
<preference for="Magento\PageCache\Model\VclGeneratorInterface" type="Magento\PageCache\Model\Varnish\VclGenerator"/>
<preference for="Magento\PageCache\Model\VclTemplateLocatorInterface" type="Magento\PageCache\Model\Varnish\VclTemplateLocator"/>
<preference for="Magento\PageCache\Model\Spi\PageCacheTagsPreprocessorInterface" type="Magento\PageCache\Model\PageCacheTagsPreprocessorComposite"/>
- <preference for="Magento\Framework\App\PageCache\IdentifierInterface" type="Magento\PageCache\Model\App\Request\Http\IdentifierForSave"/>
+ <preference for="Magento\Framework\App\PageCache\IdentifierInterface" type="Magento\Framework\App\PageCache\Identifier"/>
</config>
Previously
dev:di:info "Magento\Framework\App\PageCache\IdentifierInterface"
DI configuration for the class Magento\Framework\App\PageCache\IdentifierInterface in the GLOBAL area
Preference: Magento\PageCache\Model\App\Request\Http\IdentifierForSave
Constructor Parameters:
+-----------------------+----------------------------------------------------------------+------------------+
| Name | Requested Type | Configured Value |
+-----------------------+----------------------------------------------------------------+------------------+
| request | Magento\Framework\App\Request\Http | |
| context | Magento\Framework\App\Http\Context | |
| serializer | Magento\Framework\Serialize\Serializer\Json | |
| identifierStoreReader | Magento\PageCache\Model\App\Request\Http\IdentifierStoreReader | |
| identifier | Magento\Framework\App\PageCache\Identifier | |
+-----------------------+----------------------------------------------------------------+------------------+
Plugins:
+--------+--------+------+
| Plugin | Method | Type |
+--------+--------+------+
Plugins for the Preference:
+--------+--------+------+
| Plugin | Method | Type |
+--------+--------+------+
After the patch
dev:di:info "Magento\Framework\App\PageCache\IdentifierInterface"
DI configuration for the class Magento\Framework\App\PageCache\IdentifierInterface in the GLOBAL area
Preference: Magento\Framework\App\PageCache\Identifier\Interceptor
Constructor Parameters:
+------------+---------------------------------------------+------------------+
| Name | Requested Type | Configured Value |
+------------+---------------------------------------------+------------------+
| request | Magento\Framework\App\Request\Http | |
| context | Magento\Framework\App\Http\Context | |
| serializer | Magento\Framework\Serialize\Serializer\Json | |
+------------+---------------------------------------------+------------------+
Plugins:
+--------+--------+------+
| Plugin | Method | Type |
+--------+--------+------+
Plugins for the Preference:
+--------+--------+------+
| Plugin | Method | Type |
+--------+--------+------+
If you go back in previous versions you'll notice that it never showed IdentifierForSave and only was introduced later on which caused this error after we upgraded
Release note
No response
Triage and priority
Preconditions and environment
Steps to reproduce
on FPC hits after the login redirect).
Expected result
The PDP/PLP prices should immediately switch to the logged-in customer group price after login, because FPC should vary by X-Magento-Vary and Magento\Framework\App\PageCache\Identifier should be used for cache lookup.
Actual result
PDP/PLP continue to show the guest price until the product is added to the cart (the customer group price only appears on the cart). Investigation shows
Magento\Framework\App\PageCache\IdentifierInterface preference points to
Magento\PageCache\Model\App\Request\Http\IdentifierForSave
(which relies on HttpContext and is empty when FPC hits), so the wrong cache key is used and the vary cookie isn’t read, causing cached guest prices to be served to logged-in users.
Additional information
We solved it by injecting the correct preference here in
module-page-cachePreviously
dev:di:info "Magento\Framework\App\PageCache\IdentifierInterface"After the patch
dev:di:info "Magento\Framework\App\PageCache\IdentifierInterface"If you go back in previous versions you'll notice that it never showed IdentifierForSave and only was introduced later on which caused this error after we upgraded
Release note
No response
Triage and priority