I need to specify a ttl for a custom product block to force varnish cache invalidation on it without loosing FPC. Is there a way to get product (at least the productId) from the ESI request so that I can dynamically rebuild my block according to product attributes ?
Here is my catalog_view_view.xml (working in my theme not a specific module):
<referenceContainer name="product.info.main">
<block class="Magento\Catalog\Block\Product\View\Attributes" name="mytemplate" template="Magento_Catalog::mytemplate.phtml" ttl="100" after="product.info" />
</referenceContainer>
In my template.phtml the product is always null when the ESI request is made:
<?php $p = $block->getProduct(); ?>
the request URI looks like :
/page_cache/block/esi/blocks/%5B%22mytemplate%22%5D/handles/WyJkZWZhdWx0IiwiY2F0YWxvZ19wcm9kdWN0X3ZpZXciLCJjYXRhbG9nX3Byb2R1Y3Rfdmlld190eXBlX3NpbXBsZSIsIndlbHRwaXhlbF9nb29nbGVjYXJkc19yZW1vdmVfb3BlbmdyYXBoIl0%3D/
handles
parameter on thispage_cache/block/esi
url hashed or something? I thought that was normally a JSON encoded array, likehandles/%5B%22default%22,%22catalog_product_view%22%5D/
?