/** * Send curl purge request * to invalidate cache by tags pattern * * @param string $tagsPattern * @return void */ protected function sendPurgeRequest($tagsPattern) { $headers = ["X-Magento-Tags-Pattern: {$tagsPattern}"]; $this->_curlAdapter->setOptions([CURLOPT_CUSTOMREQUEST => 'PURGE']); $this->_curlAdapter->write('', $this->_helper->getUrl('*'), '1.1', $headers); $this->_curlAdapter->read(); $this->_curlAdapter->close(); }
/** * Replace the output of the block, containing ttl attribute, with ESI tag * * @param \Magento\Framework\View\Element\AbstractBlock $block * @return string */ protected function _wrapEsi(\Magento\Framework\View\Element\AbstractBlock $block) { $url = $block->getUrl('page_cache/block/esi', array('blocks' => json_encode(array($block->getNameInLayout())), 'handles' => json_encode($this->_helper->getActualHandles()))); return sprintf('<esi:include src="%s" />', $url); }
/** * Retrieve script options encoded to json * * @return string */ public function getScriptOptions() { $params = array('url' => $this->getUrl('page_cache/block/render/'), 'handles' => $this->helper->getActualHandles(), 'versionCookieName' => \Magento\Framework\App\PageCache\Version::COOKIE_NAME); return json_encode($params); }