I’m working on a Zend Framework project and I’m trying to figure out the best caching strategy. I have a simple setup with an Index controller that fetches a post from the database and passes it to the view. The view then displays the post title and text.
I’m wondering about the differences between caching the database result set in the controller versus caching the output in the view using the Output frontend.
Here’s a simplified version of what I’m working with:
// Controller
class IndexController extends Zend_Controller_Action
{
public function showPostAction()
{
$postModel = new PostModel();
$latestPost = $postModel->getLatestPost();
$this->view->post = $latestPost;
}
}
// View
echo $this->post->headline;
echo $this->post->content;
Does anyone know if these two caching approaches would save the same amount of system resources? I’m trying to optimize performance but I’m not sure which method would be more efficient. Any insights would be really helpful. Thanks!