Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable template caching for development in OpenCart 3

Tags:

I am making changes in my theme templates in OpenCart 3. Due to template caching I have to clear cache every time under "storage/cache" directory. It is very annoying when working and previewing changes frequently during development. Please provide some solution how we can configure caching according to production and development environment.

Note: I have already searched for solutions online but there is no solution related to template caching. Solutions are available to disable image caching but "Image Caching" and "Template Caching" are different features provided in Opencart.

like image 866
Rajat Jain Avatar asked Jul 20 '17 16:07

Rajat Jain


2 Answers

You might need to upgrade to a more recent version of OpenCart3 - the first one (3.0.0.0) didn't have a way of doing this in the GUI.

More recent versions, such as 3.0.2.0, have a gear on the admin dashboard. Click the gear and you get options to disable caching.

enter image description here

like image 179
Scott C Wilson Avatar answered Oct 26 '22 01:10

Scott C Wilson


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.

like image 28
Rupak Nepali Avatar answered Oct 26 '22 03:10

Rupak Nepali