As is typically the case with a CMS, the most hits occur while it is still "new". I'd like to cache the page output the first time it is rendered for a given period as to reduce the heavy workload that is required to generate it.
I've been working from the JCache documentation, and have the basic mechanics worked out as shown here:
$cache = JFactory::getCache('MyCache', '');
$cache->setCaching(true);
$cache->setLifeTime(86400); //24 hours
$cache_id = 'MyCache_page_123';
$cached_page= $cache->get($cache_id);
if (!empty($cached_page)) {
$the_page_output = $cached_page;
}else{
$the_page_output = ...<div>the generated view HTML</div>....
$cache->store($the_page_output, $cache_id);
}
// echo or return "$the_page_output"
I'm stuck trying to determine where I should create the cache, then the "sweet spot" to use that cache before all the work begins again.