francis
(Francis Tm)
1
I want to cache a few actions by static files, but I found COutputCache is not work if there’s no rendering in the action.
I just want to cache the actions which has no rendering, only have some text output directly or output by GD2.
Does anyone could give me some tips, thanks.
Haensel
(Johannes)
2
francis
(Francis Tm)
3
thanks for your tips and I got the solution.
I created a class extends CFilter, like below:
class CustomCache extends CFilter
{
protected function preCache($filterChain)
{
if($cond_is_not_cached) {
ob_clean();
ob_implicit_flush(false);
return parent::preCache($filterChain);
}else {
output_the_cache();
}
}
protected function postCache($filterChain)
{
$binary = ob_get_clean();
storage_bin_to_cache($binary);
echo $binary;
}
}