Skip to content

Added preloads are not used when pagecache is enabled #38

@MichielVrins

Description

@MichielVrins

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.

    public function parse(HttpResponse $response)
    {
        $this->addLinkHeadersFromResponse($response);
        $this->addLinkHeadersFromLayout();
        $this->processHeaders($response);
        $this->processBody($response);
        $this->reset();
    }

Here it attempts to add the links from the layout by retrieving the 'link-preload' block

$block = $this->layout->getBlock('link-preload');

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions