[英]Means to implement full page cache with dynamic placeholders
我想尝试创建类似Zend的Server Pagecache的东西。 我要实现的是存储页面输出,所以我想它应该是直接html,但是可以在页面中插入一些动态数据。
您始终可以使用ajax加载动态数据。 例如:如果用户登录并要投票或其他。
输出缓存是一个很大的主题。 做对了,您需要对设计进行一些思考。
这有两种方法。 该代码示例仅用于解释,不是可行的解决方案。
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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.