ZF-4667: Zend_Cache_Frontend_Action

Description

I think it would be extermely useful to have the abbility to cache actions in the same way as Zend_Cache_Forntend_Page. In init() i would setup cacheable actions, options and if cache found it would inject it directly to response....

I think now I can use Zend_Cache_Frontend_Class, but it's just too complicated to handle all the stuff around - like response segments... Or Zend_Cache_Output, but it still doesn't do the job.

Comments

I don't understand.

Is it something to implement in Zend_Cache or in Zend MVC stuff ?

Not sure where it would be the best place form implementation. My point is, that there is no easy way of chaching one specific Controller and/or some of his Actions. You can do it via URL or via caching the class, but no easy "one array config" solution.

I think of something like

Zend_Cache::registerControllerCache($array); It would setup the cache, save it in Registry and then use it in the dispatching process to find whether the action needs to be regenerated or not. Am I clear?

I'll try to write the code I'd like to use:


$frontendOptions = (array('index','index','default'),array('about','index','default'));
$cache = Zend_Cache::factory('Controller','File',$frontendOptions,$backendOptions);
//save it to Registry to some specific key
$frontController->dispatch();

//get from registry (should be auto - like Zend_Translate)
if($cache->isCachedRequest($request)){ 
// check if already cached and send stored cache to response object
} else {
// continue normally
}

if($cache->isCachedRequest($request)){ 
$cache->save($responseData);
// including response segment, view renderer state, noRender, etc...
}
//send to response

Does this help? Is there any way to do this this easily with current Zend_Cache components?

change Assignee because I'm inactive now

There is an action helper provided for this purpose: {{Zend_Controller_Action_Helper_Cache}}