New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Built-in FPC cache is broken in 2.4.7 for some configurations #38626
Comments
Hi @thlassche. Thank you for your report.
Join Magento Community Engineering Slack and ask your questions in #github channel. |
Workaround, add this in a module:
<?php
namespace <namespace>\<module>\Plugin;
use Magento\PageCache\Model\App\Request\Http\IdentifierForSave;
use Magento\Store\Model\StoreManager;
class CacheIdentifierPlugin
{
/**
* @var \Magento\Framework\View\DesignExceptions
*/
private $designExceptions;
/**
* @var \Magento\Framework\App\RequestInterface
*/
private $request;
/**
* @var \Magento\PageCache\Model\Config
*/
private $config;
/**
* @param \Magento\Framework\View\DesignExceptions $designExceptions
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\PageCache\Model\Config $config
*/
public function __construct(
\Magento\Framework\View\DesignExceptions $designExceptions,
\Magento\Framework\App\RequestInterface $request,
\Magento\PageCache\Model\Config $config
) {
$this->designExceptions = $designExceptions;
$this->request = $request;
$this->config = $config;
}
public function afterGetValue(IdentifierForSave $identifier, $result)
{
if ($this->config->getType() === \Magento\PageCache\Model\Config::BUILT_IN && $this->config->isEnabled()) {
$identifierPrefix = '';
/* @phpstan-ignore-next-line */
$ruleDesignException = $this->designExceptions->getThemeByRequest($this->request);
if ($ruleDesignException !== false) {
$identifierPrefix .= 'DESIGN' . '=' . $ruleDesignException . '|';
}
/* @phpstan-ignore-next-line */
if ($runType = $this->request->getServerValue(StoreManager::PARAM_RUN_TYPE)) {
$identifierPrefix .= StoreManager::PARAM_RUN_TYPE . '=' . $runType . '|';
}
/* @phpstan-ignore-next-line */
if ($runCode = $this->request->getServerValue(StoreManager::PARAM_RUN_CODE)) {
$identifierPrefix .= StoreManager::PARAM_RUN_CODE . '=' . $runCode . '|';
}
return $identifierPrefix . $result;
}
return $result;
}
}
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\PageCache\Model\App\Request\Http\IdentifierForSave">
<plugin name="core-app-area-design-exception-plugin"
type="<namespace>\<module>\Plugin\CacheIdentifierPlugin" sortOrder="10"/>
</type>
</config>
|
Hi @engcom-Hotel. Thank you for working on this issue.
|
Hello @thlassche, Thanks for the report and collaboration! We have tried to reproduce the issue in both 2.4.7 and 2.4-develop and the issue is reproducible in both instances. But if we remove Hence confirming the issue. Thanks |
✅ Jira issue https://jira.corp.adobe.com/browse/AC-11819 is successfully created for this GitHub issue. |
✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue. |
@magento I am working on this |
I added a fix with the PR 38646. There is no automated tests at this time but the fix was added in the 2.4-develop branch and I verified both 2.4.7 and 2.4-develop had this issue |
Preconditions and environment
MAGE_RUN_CODE
parameter setSteps to reproduce
Expected result
Page is cached, and in developer mode a header
X-Magento-Cache-Debug: HIT
is setActual result
Page is uncached, and in developer mode a header
X-Magento-Cache-Debug: MISS
is setAdditional information
In 2.4.7 the identifier for saving a page to cache was decoupled from the fetching identifier:
magento2/app/code/Magento/PageCache/Model/App/Request/Http/IdentifierForSave.php
Line 18 in 725b648
However the fetching identifier has plugins on it that prepend the cache key with some parameters:
magento2/app/code/Magento/PageCache/Model/App/CacheIdentifierPlugin.php
Line 67 in 725b648
That plugin is not added to the saving part, hence the key will always mismatch if there are additional parameters
Release note
No response
Triage and priority
The text was updated successfully, but these errors were encountered: