PageCaching: different dependency for different actions

I’ve started playing around Yii 2 fragment caching with their dependency and added page caching on top of it with a single query that will invalidate the cache in any of the active records gets updated.

now in the controller where I did define my page caching, I have two actions, one that does have the dynamic data and where the fragment caching happens, and another one which is completely static.

Clearly with the following configuration of the page cache:

            'pageCache' => [

                'class' => 'yii\filters\PageCache',

                'only' => ['index', 'terms'],

                'duration' => 3600, // in seconds

                'dependency' => [

                    'class' => 'yii\caching\DbDependency',

                    'sql' => 'SELECT GREATEST( MAX( v.mtime ) , MAX( p.mtime ) ) FROM video v, promotion p',



when I request the static page I still get one query being executed from the dependency.

Is there any way to avoid that and configure dependencies selectively?

and is it also possible to define different durations for different actions?

sorry for bumping the thread, but I can’t find any information regarding this.

one of the things I thought might work is by using chained caching, although I might just have made that one up as I can’t find sources to back up my assertion :P