I have a user portal that gathers information from multiple
controllers. The logic belongs in those controllers. The portal
obtains these viewlets via requestAction() calls. RequestAction is
notoriously slow and had no chance of using the view cache. This has
really sped up my requestAction calls that are database and logic
heavy.
I modified my dispatcher.php dispatch method to first look for a cache
if its an internal call...
if (!empty($additionalParams) && !empty($additionalParams['cache']))
{
// requestAction had no prior chance to get cached
version so check
here
if (defined('CACHE_CHECK') && CACHE_CHECK === true) {
$uri = Router::url($url);
if (empty($uri)) {
$uri = setUri();
}
if (!isset($TIME_START)) {
$TIME_START = getMicrotime();
}
if (strpos($uri,'/bare/')===false) { // we want
to force a bare
cache
$filename = CACHE . 'views' . DS .
'bare_' . convertSlash($uri) .
'.php';
} ele {
$filename = CACHE . 'views' . DS .
convertSlash($uri) . '.php';
}
if (file_exists($filename)) {
uses('controller' . DS . 'component',
DS . 'view' . DS . 'view');
$v = null;
$view = new View($v);
if ($view->renderCache($filename,
$TIME_START, false)) {
return;
}
} elseif(file_exists(CACHE . 'views' . DS .
'bare__' .
convertSlash($uri) . '_index.php')) {
uses('controller' . DS . 'component',
DS . 'view' . DS . 'view');
$v = null;
$view = new View($v);
if ($view->renderCache(CACHE . 'views'
. DS .
convertSlash($uri) . '_index.php', $TIME_START)) {
return;
}
}
}
}
and modified my View::renderCache to accept a third parameter
function renderCache($filename, $timeStart, $dieOnSuccess = true) {
and not die(); in there if it is false.
If this is not formatted in your email, see http://lloydhome.com/news/
view/6.
Also, I have posted an article on user authentication within cached
pages at http://lloydhome.com/news/view/5. It is a Smarty article but
it is usable for ctp and thtml files that are cached and need a
controller's beforeFilter() run to allow user authentication.
- David Lloyd
--
lloydhome consulting, inc.
http://lloydhome.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---