[Konstantin Gによる。]{class="badge informative" title="コンスタンティン・G。"} [PaaS のみ]{class="badge informative" title="Adobe Commerce on Cloud プロジェクト(Adobeが管理する PaaS インフラストラクチャ)およびオンプレミスプロジェクトにのみ適用されます。"}
Varnish ESI ブロックの設定 varnish-esi-block
Edge Side Includes (ESI)は、他のweb ページにweb ページを含めるために使用できる特別なディレクティブです。
例:
<div>
<esi:include src="http://domain.com/index.php/page_cache/block/esi/blocks"/>
</div>
Varnishはhttp://domain.com/index.php/page_cache/block/esi/blocksからコンテンツを取得し、<esi> タグをそれに置き換えます。
CommerceとVarnish ESI
次の条件が満たされると、Commerce フレームワークによってESI タグが作成されます。
- キャッシュ アプリケーションは
Varnish Cacheに設定されています - XML レイアウト
block要素がttl属性とともに追加されました
例
cms_index_index.xml:
<referenceContainer name="content">
<block class="Magento\Framework\View\Element\Template" template="Magento_Paypal::esi.phtml" ttl="30"/>
</referenceContainer>
上記の例では、block要素がesi.phtml テンプレートのコンテンツをホームページに追加し、Varnishが30秒ごとに自動的に更新します。
制限
現在、VarnishはHTTPS経由のESIをサポートしていないため、HTTPに自動的に切り替わります。
Magento\PageCache\Observer\ProcessLayoutRenderElement:
private function _wrapEsi(
\Magento\Framework\View\Element\AbstractBlock $block,
\Magento\Framework\View\Layout $layout
) {
....
// 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);
}
recommendation-more-help
386822bd-e32c-40a8-81c2-ed90ad1e198c