Answer the question
In order to leave comments, you need to log in
Why is the cache not updating?
I had such a problem when I wanted to cache the page, used http caching, then I got that some data after the redirect remained and remains in its place, although there is a status of 200
Here is my code in the controller
public function behaviors()
{
return [
'caching' => [
'class' => 'yii\filters\HttpCache',
'only' => ['admin', 'shop', 'master', 'disain'],
'lastModified' => function(){
return Zakaz::find()->max('date_update');
}
],
]
}
public function actionFulfilled($id)
{
$model = $this->findModel($id);
$model->status = self::STATUS_EXECUTE;//меняется статус на закрытие
if ($model->save()) {
Yii::$app->session->addFlash('update', 'Выполнен заказ №'.$model->prefics);
return $this->redirect(['admin']);
} else {
print_r($model->getErrors());//если ошибка то пишет проблему
}
}
public function behaviors()
{
return [
[
'class' => 'yii\behaviors\TimestampBehavior',
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['date_update'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['date_update'],
]
]
];
}
public function rules()
{
return [
...
[['date_update'], 'integer']
]
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question