1

We have a setup with a public facing NGINX reverse proxy that sets the head X-Magento-Store and the shop instance on an apache Vhost

in apache I added

    SetEnv MAGE_RUN_TYPE "store"

    SetEnvIfNoCase X-Magento-Store ^english$ MAGE_RUN_CODE=english
    SetEnvIfNoCase X-Magento-Store ^italian$  MAGE_RUN_CODE=italian

And every thing works fine as long as full_page cache is off.

If full_page cache is on, and I open the Italian URL www.example.com/it-it/shop first, the Italian start page is also shown when opening www.example.com/en_gb/shop and vice versa.

So it seems to me that the store code is missing in the full_page cache key some how, but why?

Steps to reproduce, without proxy setup:

1) In pub/.htaccess set

SetEnv MAGE_RUN_TYPE store SetEnv MAGE_RUN_CODE italy

2) Now open Frontend

3) Now set

SetEnv MAGE_RUN_TYPE store SetEnv MAGE_RUN_CODE english

4) Now Open frontend, same URL

-> Italian version is displayed

Debugging

Setting break point in \Magento\Framework\App\PageCache\Kernel::load

1 Answer 1

0

The code in \Magento\Framework\App\PageCache\Identifier::getValue get's the value for the cache key. In our case, the UriString is always the same, so the same data is returned

public function getValue()
{
    $data = [
        $this->request->isSecure(),
        $this->request->getUriString(),
        $this->request->get(\Magento\Framework\App\Response\Http::COOKIE_VARY_STRING)
            ?: $this->context->getVaryString()
    ];
    return sha1($this->serializer->serialize($data));
}

A temporary workaround would be to insert the MAGE_RUN_CODE to the function, but I will work on a better way

public function getValue()
{
    $data = [
        $this->request->isSecure(),
        $this->request->getUriString(),
        $this->request->getServerValue('MAGE_RUN_CODE'),
        $this->request->get(\Magento\Framework\App\Response\Http::COOKIE_VARY_STRING)
            ?: $this->context->getVaryString()
    ];
    return sha1($this->serializer->serialize($data));
}

It is submitted as a pending pull request:

https://github.com/magento/magento2/pull/18624

https://github.com/magento/magento2/pull/18624/commits/d12da9fa10a22443d886ecdcd6a995a36374df2f.patch

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.