Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to disable cache in volt when development

Hi all I use template engine, but when development cache has been create, i want to disable,


You can set a config variable say "debug" and based on that compile the templates or not.

Have a look at this

                        if ('1' != $config->application->debug) {
                            $voltOptions['compileAlways'] = true;

compileAlways for volt means no cache


Thank you,I ask, how to display code as above

I ran into a problem with this as well. Very ocassionally, Volt will fail to realize that a template file has changed, which can be frustrating in dev when you're changing things constantly. I solved it by adding this block to my service definition.

 * Clear out the Volt cache dir on every request in debug mode.
 * Volt appears to have no capacity to compile itself to memory; it always
 * needs to write its output to file and sometimes the engine doesn't
 * realize that a template has changed, so it doesn't re-compile it.
if ($config->application->debugMode) {
  array_map('unlink', glob($config->application->cacheDir . 'volt/*.php'));
    'compileAlways' => TRUE,