public function behaviors()
{
$post = $this->findModel(Yii::$app->request->get('id'));
return [
'httpCache' => [
'class' => 'yii\filters\HttpCache',
'only' => ['view'],
'lastModified' => function ($action, $params) use ($post){
return strtotime($post->updated);
},
'etagSeed' => function ($action, $params) use ($post) {
return serialize([$post->updated, $post->views, $post->comments, Yii::$app->user->isGuest ? 0 : 1]);
}
],
];
}