我想尝试创建类似Zend的Server Pagecache。我想要实现的是存储页面输出,所以我想这将是直接的html,但有可能向页面插入一些动态数据。
答案 0 :(得分:0)
您始终可以使用ajax加载动态数据。 例: 如果用户登录并投票或其他什么。
答案 1 :(得分:0)
输出缓存是一个很大的主题。做得对,你需要在设计上思考一下。
这是两种方式。代码示例仅用于解释,它不是一个可行的解决方案。
class CachedController extends Zend_Action_Controller
{
public function indexAction()
{
$this->_view->leftBlock = $this->leftBlock();
$this->_view->rightBlock = $this->rightBlock();
}
protected function leftBlock()
{
// prepare left block, can use Zend_View if you like
// use Zend_Cache to cache the block
}
protected function rightBlock()
{
// prepare left block, can use Zend_View if you like
// use Zend_Cache to cache the block
}
}
/* VIEW SCRIPT */
<html>
<body>
<div class="left">
Left cached block here
<?php echo $this->leftBlock; ?>
</div>
<div class="main">
Do Your dynamic part here
</div>
<div class="right">
Right cached block here
<?php echo $this->rightBlock; ?>
</div>
</body>
</html>