The great thing about about the Zend Framework is that the components are so well made. There is an automatic page caching algorithm in Zend_Cache. Of course, it is not perfect since I have my own use-case. Besides, I am not sure that it works with Zend_Layout.
The solution is Veneer_Cache. I simply wrap Zend_Cache. The was noplace in the controller that I could pick up all the HTML. There probably is in Layout but it is subject to change. I decided to try a plugin.
public function dispatchLoopShutdown()
{
$registry = Zend_Registry::getInstance();
$msite_config = $registry->get('msite_config');
if($msite_config->cacheOn==1) {
if($registry->get('cacheable')) {
$body = $this->getResponse()->getBody();
$cache = $registry->get('cache');
$cache->pgSave($body);
}
}
}
If the configuration says to have the cache on AND I decide in the action that I want to cache it, it will be done automatically. I hash the URL to see if there is a cached copy of the page. If there is, I display it. It makes the logic fairly simple.
Thursday, October 25, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment