Skip to content
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

Open
1 of 5 tasks
thlassche opened this issue Apr 17, 2024 · 9 comments · May be fixed by #38646
Open
1 of 5 tasks

Built-in FPC cache is broken in 2.4.7 for some configurations #38626

thlassche opened this issue Apr 17, 2024 · 9 comments · May be fixed by #38646
Assignees
Labels
Area: Framework Component: PageCache Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: PR in progress Reported on 2.4.7 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@thlassche
Copy link
Contributor

thlassche commented Apr 17, 2024

Preconditions and environment

  • Magento version: 2.4.7
  • Use built in FPC
  • Have aMAGE_RUN_CODE parameter set

Steps to reproduce

  1. Enable built-in FPC
  2. Have a MAGE_RUN_CODE parameter in your $_SERVER array
  3. Load a frontend page
  4. Load the same page again

Expected result

Page is cached, and in developer mode a header X-Magento-Cache-Debug: HIT is set

Actual result

Page is uncached, and in developer mode a header X-Magento-Cache-Debug: MISS is set

Additional information

In 2.4.7 the identifier for saving a page to cache was decoupled from the fetching identifier:

class IdentifierForSave implements IdentifierInterface

However the fetching identifier has plugins on it that prepend the cache key with some parameters:

$identifierPrefix .= StoreManager::PARAM_RUN_TYPE . '=' . $runType . '|';

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

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Copy link

m2-assistant bot commented Apr 17, 2024

Hi @thlassche. Thank you for your report.
To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:


Join Magento Community Engineering Slack and ask your questions in #github channel.
⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
🕙 You can find the schedule on the Magento Community Calendar page.
📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

@thlassche
Copy link
Contributor Author

Workaround, add this in a module:

<namespace>\<module>\Plugin\CacheIdentifierPlugin.php
<?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;
    }
}
<namespace>\<module>\etc\frontend\di.xml
<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>

@engcom-Dash engcom-Dash added Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it Reported on 2.4.7 Indicates original Magento version for the Issue report. labels Apr 17, 2024
@engcom-Hotel engcom-Hotel self-assigned this Apr 18, 2024
Copy link

m2-assistant bot commented Apr 18, 2024

Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Hotel
Copy link
Contributor

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 MAGE_RUN_CODE, the X-Magento-Cache-Debug is showing as HIT. Please refer to the below screenshot for reference:

With MAGE_RUN_CODE
247

Without MAGE_RUN_CODE
247_wo_mageruncode

Hence confirming the issue.

Thanks

@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: PageCache Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Area: Framework and removed Issue: ready for confirmation labels Apr 18, 2024
@m2-community-project m2-community-project bot added this to Dev In Progress in High Priority Backlog Apr 18, 2024
@m2-community-project m2-community-project bot removed this from Ready for Confirmation in Issue Confirmation and Triage Board Apr 18, 2024
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-11819 is successfully created for this GitHub issue.

Copy link

m2-assistant bot commented Apr 18, 2024

✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@digitalrisedorset
Copy link

@magento I am working on this

@digitalrisedorset
Copy link

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

@ThisIsRuddy
Copy link

Cheers @digitalrisedorset

magento-module-page-cache-fpc-identifier.patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Component: PageCache Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: PR in progress Reported on 2.4.7 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
High Priority Backlog
  
Pull Request In Progress
6 participants