Cache always make developer scream out in some of the case developers write the code correctly but they forget to clear the cache and they test the logic and data which they found it not working, as cache provides stale data and logic, they scream out loud and after some hours of testing and logical changes they remember to clear the cache 🙂 and they again scream out. The same case happens when I started to develop an OpenCart extension for OpenCart Version and I keep on testing the module but it does not show the changes as it is showing from the Cache folder which is at storage/ folder that you keep outside of the public_html folder in your server. In OpenCart Version 2.*  it used to be in system/storage.

How to remove the twig template cache in OpenCart Version

1. Click this setting icon on the dashboard
2. Then this popup shows then off the cache and click the refresh button

Another way is:

Open system\library\template\Twig\Environment.php, in the constructor:

public function __construct(Twig_LoaderInterface $loader = null, $options = array())
    if (null !== $loader) {
    } else {
        @trigger_error('Not passing a Twig_LoaderInterface as the first constructor argument of Twig_Environment is deprecated since version 1.21.', E_USER_DEPRECATED);

    $options = array_merge(array(
        'debug' => false,
        'charset' => 'UTF-8',
        'base_template_class' => 'Twig_Template',
        'strict_variables' => false,
        'autoescape' => 'html',
        'cache' => false,
        'auto_reload' => null,
        'optimizations' => -1,
    ), $options);

    $this->debug = (bool) $options['debug'];

Find the following line of code:

$this->debug = (bool) $options['debug'];

and change it to:

$this->debug = (bool) true;

Then your template file caching will be removed.

Another way to do this:

Open to system\library\template\Twig\Cache\Filesystem.php, find following lines of code

public function load($key)
    if (file_exists($key)) {
        @include_once $key;

Comment out as in the following code:

public function load($key)
    // if (file_exists($key)) {
    //      @include_once $key;
    // }

This will remove the template cache of the twig and recreate every time, once development is over you have to remove the comment.

Hope it will help your development time so that you don’t have to keep on clearing the cache for each test.

Rupak Nepali


  1. Hi,

    I noticed a problem with v3.0.2.0 after creating a site on a2hosting. Anytime I create a folder or upload image , it won’t show up immediately. I have to logout and login again to see new folders or new images. It works without problem in local PC though. Is this something related to this caching?


Please enter your comment!
Please enter your name here