H
H
hollanditkzn2017-10-24 11:53:20
Yii
hollanditkzn, 2017-10-24 11:53:20

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());//если ошибка то пишет проблему
        }
    }

In the model
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']
]
}

That's constantly after the redirect, as the record remains in place, it remains, unless you update the page itself, then it leaves. This changes the date_update value. And then when I restore, then again nothing changes, only you need to update with clearing the cache, then everything works

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
M
Maxim Timofeev, 2017-10-24
@hollanditkzn

You
and you are talking about Fulfilled

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question