0

In one of our project website started loading very slow and I found out all caches were disabled which I have enabled earlier.

I can figure out the following ways through which caches can get disabled:

  • When someone runs php bin/magento cache:disable command.
  • When someone modifies app/etc/env.php and disables caches from there.
  • Under certain circumstances a file .regenerate is written in the var folder (either at setup upgrade or composer install / upgrade) and if that file is present when running php bin/magento setup:di:compile the cache is disabled and re-enabled when the compilation process is finished. For some reason, sometimes the cache is not re-enabled. (Referenced from here)

What are the other possibilities through which

  • Someone having code/db access can disable it ?
  • Automatically it can get disabled ?
0

In developer mode the option on backend is available to disable any cache from backend

Whereas in production mode, this option is not available, so you need to do it by command.

To disable all cache you need to run this as you already added in question:

php bin/magento cache:disable

And if you need to disable on cache, then disable it by it's tag name

Example:

magento cache:disable full_page

There is no database entry for these cache types, if you disable any cache from command, then it will update entry in env.php, and if you do it from admin then this method will also update entry in env.php

You wont find any other way to disable cache. You can disable it either from shell or from admin or directly from env.php

Hope this is the answer of your question.

0

This is known issue in Magento 2.2: https://github.com/magento/magento2/issues/17634

In this path: magento2/lib/internal/Magento/Framework/Code/GeneratedFiles.php. This is the code which disables the cache other than scenarios you mentioned in your answer

$deploymentConfig = $this->directoryList->getPath(DirectoryList::CONFIG);
            $configPool = new ConfigFilePool();
            $envPath = $deploymentConfig . '/' . $configPool->getPath(ConfigFilePool::APP_ENV);
            if ($this->write->isExist($this->write->getRelativePath($envPath))) {
                $enabledCacheTypes = $this->getEnabledCacheTypes();
                $this->disableAllCacheTypes();
            }

I hope this will help

  • Unfortunately I have mentioned it in my third scenario. – amitshree Jul 10 at 6:54
  • @amitshree so have you removed the code or updated your magento version? It may be the cause and also you mentioned in your question by asking the code which influence the cache – Muhammad Hasham Jul 10 at 6:56
  • I have not removed the code or updated Magento version. I have disabled Inventory modules starting with Magento_Inventory and afterwards I ran upgrade, di compile and static content deployment commands. – amitshree Jul 10 at 7:00
  • In my opinion, it is not the best practices to disable your Inventory modules. I would not rate it as permanent and proper solution. Anyways it's up to you, every body has their own opinion and way of doing things – Muhammad Hasham Jul 10 at 7:11
  • One of the optimization tips of Magneto is that disable modules which are not used/required for you project. Why not disable Magento_Inventory modules? – amitshree Jul 10 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.