It is an action filter that can be added to a controller and handles the beforeAction event.
To use PageCache, declare it in the behaviors() method of your controller class.
In the following example the filter will be applied to the index action and
cache the whole page for maximum 60 seconds or until the count of entries in the post table changes.
It also stores different versions of the page depending on the application language.
php
public function behaviors()
{
return [
'pageCache' => [
'class' => 'yii\filters\PageCache',
'only' => ['index'],
'duration' => 60,
'dependency' => [
'class' => 'yii\caching\DbDependency',
'sql' => 'SELECT COUNT(*) FROM post',
],
'variations' => [
\Yii::$app->language,
]
],
];
}