6

I went through an article about MAGENTO 2 CACHING OVERVIEW https://alankent.me/2014/12/09/magento-2-caching-overview/

It tells Magento uses ajax and basically rely on JS for showing private content.

But if we search in magento vendor directory, It uses ESI tags.

protected function _wrapEsi(
    \Magento\Framework\View\Element\AbstractBlock $block,
    \Magento\Framework\View\Layout $layout
) {
    $url = $block->getUrl(
        'page_cache/block/esi',
        [
            'blocks' => json_encode([$block->getNameInLayout()]),
            'handles' => json_encode($layout->getUpdate()->getHandles())
        ]
    );
    // Varnish does not support ESI over HTTPS must change to HTTP
    $url = substr($url, 0, 5) === 'https' ? 'http' . substr($url, 5) : $url;
    return sprintf('<esi:include src="%s" />', $url);
}

I am not sure, how magento uses ESI. Hope if anybody could explain.

6

Magento uses ESI to isolate navigation block from other content. The main effect of ESI is separate TTL for part of the page. However, Magento uses the isolation effect of ESI in order to minimize the count of pages which need to be invalidated during updates in category entity. The navigation block is present on every page in Magento, this means that any update in category entity will flush the whole cache for all pages. This is unacceptable. Thus we decided to use ESI here.

Private content should be ignored by all middlewares, so varnish ESI is not suitable for these purposes and should be used only for public content.

EDIT: The article you are referring is probably a bit outdated. Here is the fresh one - http://devdocs.magento.com/guides/v2.2/extension-dev-guide/cache/page-caching/private-content.html

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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