HttpCache active but yii debuger has executed database queries


Is it normal behavior when the HttpCache is active the Yii Debugger still indicates Yii executed database queries?

The behaviors method in my controller looks like:

public function behaviors()


        return [

            'verbs' => [

                'class' => VerbFilter::className(),

                'actions' => [

                    'delete' => ['POST'],




                'class' => 'yii\filters\HttpCache',

                'only' => ['view'],

                'lastModified' => function ($action, $params) {

                    $q = new \yii\db\Query();

                    return strtotime($q->from('Extension')->where(['id' => $_GET['id']]) ->max('UpdatedAt'));


//            'etagSeed' => function ($action, $params) {

//                return // generate ETag seed here

//            }




When I navigate to my view page the HTTP status is 304, which is as expected.

Image ->

But I would expect that the Yii Debugger won’t execute a Database Query, while he still executes all queries.

Image ->

| Q | A

| ---------------- | —

| Yii version | 2.0.10

| PHP version | 5.6.25

| Operating system | Windows 10

|Apache | Apache/2.4.23 (Win64) PHP/5.6.25

HttpCache is only client-side. If the request comes in, Yii deals with it without caching.

You might want page-caching:

At the moment it doesn’t seems logic to me.

If this post is correct (source:

As the server knows when to return a HTTP status 304 (Not Modified), why does he still deals with the request?

The website in development won’t have a huge amount of users, nearly a handful users on a day.

So page caching won’t improve the performance drastically.

I hope my conclusion about page caching is correct?

You may be getting a cached response along with Yii Debugger output. Check if there’s actual query made.



It must be caching.

Did my tests again with ‘Neor Profile SQL’

When pressing ‘F5’ on the page, Yii executes two queries.

When pressing ‘SHIFT’ + ‘F5’ all database queries are executed.


The caching mechanism works as expected.