[eluser]coolfactor[/eluser]
[quote author="chobo" date="1186282535"]Just one more quick question. Is there a way or technique to specify a cache time for partial views in a function? I've searched around and couldn't find an implementation for that. Thanks![/quote]
That's a popular question here. No, there is no way with the current cache mechanism. Different ideas have been tossed around for how to implement partial caching. The trick is to do it in such a way that all the processing needed by the partial is avoided if the partial is already cached and hasn't timed out.
I may integrate this into my View library, and it would use the following type of implementation:
Code:
if ($this->view->partIsNotCached('main_content')) {
// ... do all the processing needed to render the part
// render the part
$this->view->cachePart('main_content', 'path/to/partial/view');
}
In my own projects, I haven't found a great enough need to add in partial caching. The added overhead of checking to see if a partial is already cached would cancel out the benefits of caching the partial anyway. To get around that, the caching mechanism could load in all the cache files once into an array, but then we're using up memory that affects performance.
So, I'd really like someone to illustrate an example of where partial caching would provide any significant performance improvement. If it is to avoid database caching, well there's plenty that can be done on that front to improve performance, including database caching, which is a feature of CodeIgniter.