Open MichielVrins opened 2 years ago
Best option is likely to move the responseplugin to hook in on Magento\Framework\View\Result\Layout instead (with high sortorder so it goes last), this one will get cached by Pagecache
Sorry for not having responded for quite some time. I've tested this behaviour back then, but could not find any issues. And I checked it again, but am not able to duplicate. In short, if I'm enabling FPC, reload the page so that the X-Magento-Cache-Debug
header shows a HIT
, then I can also see the Link
headers added through this extension. This is under Magento 2.4.3 and 2.4.6 (in both Developer Mode and Production Mode).
Could you share your details and environment specifics?
I don't think it's about the link header data because that is present all the time. But the HTML preload link is affected by this issue described here.
So, clearing the full_page cache and loading the page:
After reloading the page:
Those are added like:
<referenceBlock name="link-preload">
<arguments>
<argument name="fonts" xsi:type="array">
<item name="foo" xsi:type="string">fonts/foo.woff2</item>
... and so on ...
</argument>
</arguments>
</referenceBlock>
In the custom-theme/Magento_Theme/layout/hyva_default.xml
.
Maybe to comment on this, the links that @Morgy93 are not added by this extension, but are added by the Magento core via \Magento\Framework\View\Page\Config\Renderer::renderAssets
. And indeed, I have tested for this, the assets are added by Magento but then removed with FPC enabled. This seems to be a core bug.
Maybe to comment on this, the links that @Morgy93 are not added by this extension, but are added by the Magento core via
\Magento\Framework\View\Page\Config\Renderer::renderAssets
. And indeed, I have tested for this, the assets are added by Magento but then removed with FPC enabled. This seems to be a core bug.
Are you sure?
Because if I disable $response->setBody($body);
via https://github.com/yireo/Yireo_LinkPreload/blob/1.4.22/Link/LinkParser.php#L120 there is no output at all.
So, for me it seems that it is added by this extension.
Just the $this->links
is different with and without cache. Maybe that's the core bug you mentioned?
@jissereitsma Any insights for my previous comment?
The preload tags and http header links are added onto the http response (presumably) after magento saves it into page cache. With page cache enabled the first load will have all the preloads in the http header and in the
but on the second load, when the page is cached in full_page cache, some of these preloads disappear.A little bit of debugging brought me to the following piece of code.
Here it attempts to add the links from the layout by retrieving the 'link-preload' block
This is however not possible, since the layout doesn't get generated since we're loading a page that is in full_page cache. This results in the added layout items not being added.
I believe a way of solving this is by caching the links in magento somewhere (specific to a page) and then using that cache to build the preload links when a page is in full_page cache.