Yireo_NextGenImages icon indicating copy to clipboard operation
Yireo_NextGenImages copied to clipboard

Module not compatible with Varnish

Open rommelfreddy opened this issue 2 years ago • 2 comments

Hello @jissereitsma

if found the issue, that the module will not work for esi blocks.

by loading the ESI blocks Magento will only render the block itselfs and is not using the method Magento\Framework\View\LayoutInterface::getOutput.

Example: The menu of Magento is a ESI Block (block with TTL). So Magento replaces it with the placeholder for varnish. So your module will not replace the images, cause in the second step (loading the ESI Block) only the function Magento\Framework\View\Element\AbstractBlock::toHtml is called.

-- Suggestion: Maybe it would be a good idea to process every block instead the whole output (event subscriber on view_block_abstract_to_html_after). So the changes by the module will be also cached by its parents block.

rommelfreddy avatar Apr 27 '22 09:04 rommelfreddy

Thanks for the suggestion. I have worked upon this with a new commit waiting to be released with the next major version of NextGenImages: https://github.com/yireo/Yireo_NextGenImages/commit/b32a758486fb84d645e87806cea26b92db137c16 The suggestion for listening to the event is indeed the way I went for, except for I don't want to apply it to any block (for performance reasons) but only those blocks with a ttl higher than zero (because those are turned into ESI blocks) and only when FPC is enabled. It works for me. But it needs to wait for the next major release before everyone else can enjoy.

jissereitsma avatar Apr 27 '22 17:04 jissereitsma

The new release has been made a couple of days ago: 0.3.0 - does that fix things for you?

jissereitsma avatar May 09 '22 17:05 jissereitsma