S
S
shik02021-10-11 00:10:59
Yii
shik0, 2021-10-11 00:10:59

Is it possible to set up Last-Modified in yii2?

Welcome all. Can you please tell me how to set lastmod headers in yii2?
Will it be necessary to run through the database, tracking changes in all records that are displayed on the page and look at the date the file structure of the views was changed (including nested ones)? Or is there some other solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2021-10-11
@shik0

The documentation even has an example from a controller:

public function behaviors()
{
    return [
        [
            'class' => 'yii\filters\HttpCache',
            'only' => ['index'],
            'lastModified' => function ($action, $params) {
                $q = new \yii\db\Query();
                return $q->from('post')->max('updated_at');
            },
        ],
    ];
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question