Hello everyone, I have a problem when using HttpCache. I return the controller action as an image and cache it via HttpCache like this
public function behaviors()
{
return [
'access' => [
'class' => AccessControl::class,
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
'cache' => [
'class' => HttpCache::class,
'only' => [
'image'
],
'lastModified' => function ($action, $params) {
$p = $this->user->profile;
if (!empty($p->updated_at)) {
return $p->updated_at;
}
return time();
},
'sessionCacheLimiter' => 'public'
]
];
}
public function actionImage($path) {
return \Yii::$app->response->sendFile("{$this->userdir}{$path}");
}
That is, instead of specifying the real path to the image, I use an action that simply returns the image along some relative path. The image caches fine, but it doesn’t get updated even when updated_at property in table changes. What am I doing wrong? Only Cntrl+F5 (Command+R) helps to see new image.