M
M
Michael2018-01-11 22:31:41
Yii
Michael, 2018-01-11 22:31:41

How to disable caching in yii2?

Yii2 uses file caching by default:

'cache' => [
    'class' => 'yii\caching\FileCache',
],

I would like to disable it in the dev version. Tried false or null: doesn't work.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Artem, 2018-01-11
@springimport

<?php
$config = [
    'aliases' => [
        '@bower' => '@vendor/bower-asset',
        '@npm'   => '@vendor/npm-asset',
    ],
    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
    'components' => [
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
    ],
];

if(YII_ENV == YII_ENV_DEV){
    unset($config['components']['cache']);
}

return $config;

And at the entry point, look at what is in the final config. Perhaps in some of the configs that are merged later, this component is overridden

S
shod, 2019-03-13
@shod

You can just replace it with
'class' => 'yii\caching\DummyCache'

I
Igor Vasiliev, 2019-05-02
@Isolution666

Maybe we are talking about the following file: And then change the checkbox:

...
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=localhost;dbname=****',
            'username' => '****', 
            'password' => '****',
            'charset' => 'utf8',
            'enableSchemaCache' => false, //  Вместо `true` поставить `false` и обновить через Ctrl+F5 или Cmd + R (Mac OS)
            'schemaCacheDuration' => 3600,
            'schemaCache' => 'cache',
        ],
...

Everything! Cash was blown away by the wind)))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question