Hi we have a Magento store. (2.3.6) ...
... and have the problem with the store switcher switching to wrong / outdated pages. We simply need the corresponding page in the other store/language to be the correct one.
I found out the following.
The is switcher works by writing a base64 encoding URL string (uenc) into the data-post attribute for each different language page via /magento/module-store/Block/Switcher.php->getTargetStorePostData().
Problem
When the page is regenerated, the store switcher takes the correct URL of the other-language page. However, once the cache is filled and the page comes out of the cache, the old opposite page (which was correct when the cache was filled) remains on all other pages. This is wrong/outdated when the page comes out of the cache. The function and template will also not be called again.
Example:
- Cache emptied
- call en_EN/page1 (uenc is correct)
- store switch to en_EN/page1 redirects correctly
- from en_EN/page1 switch to en_EN/page2
- but here is now in the switchertemplate a string that leads to de_DE/page1 instead of page2 (testable on the conslole with php -a and echo base64_decode(strtr('uencstring', '-_,', '+/='));
- the store change is executed accordingly to de_DE/page1
What I need is that the switcher block is not cached once for all pages but it should be cached seperately for each page. Does anyone have any idea how to set for individual blocks to be re-cached for each different url. Is the problem otherwise known I haven't found anything about it?
What I tried:
- I tried to set the block in the theme to no-cache, which I think is a bad solution though. Since the whole page is then no longer cached.
- $block->setCacheLifetime(0);in the block.
Info about our setup.
- Magento 2.3.6 store (and that can't be changed).
- varnish full page cache.
- custom theme (magetigue/templatemonster theme/007)