how to extending COutputCache

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.

This extension may be helpful:

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) {



            return parent::preCache($filterChain);

        }else {




    protected function postCache($filterChain)


        $binary = ob_get_clean();


        echo $binary;