It is an action filter that can be added to a controller and handles the beforeAction event.
To use HttpCache, declare it in the behaviors() method of your controller class.
In the following example the filter will be applied to the list-action and
the Last-Modified header will contain the date of the last update to the user table in the database.
php
public function behaviors()
{
return [
[
'class' => 'yii\filters\HttpCache',
'only' => ['index'],
'lastModified' => function ($action, $params) {
$q = new \yii\db\Query();
return $q->from('user')->max('updated_at');
},
'etagSeed' => function ($action, $params) {
return // generate ETag seed here
}
],
];
}