So normally when implementing FPC we'll holepunch certain blocks out that have dynamic data. What I can't seem to figure out, is there not a way to holepunch a url. So for example if we have /index/index with the following:
class Namespace_Module_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$jsonArray = array('time'=>time());
$response = Mage::helper('core')->jsonEncode($jsonArray);
$this->getResponse()->setBody($response);
}
}
Obviously with FPC enabled we'll always get the same JSON. Is there a way to holepunch a URL so that we can just always return up to date times? (Obviously I'm not using Magento just to return times, but it's a good example of dynamic data)
One alternative I can think of is to just create a block that will house the json through maybe a text block or something, but I was wondering if there was some way to do this without actually constructing a block. (Theoretically version shouldn't matter? But if it does let's say EE 1.13)
Best Answer
You'll need to define a container and a placeholder in your module.
Model/Pagecache/Container.php
etc/cache.xml
Be sure and read over Vinai's details on how the FPC works:
Boilerplate container and placeholder code from: