phptemplatessmartysmarty-plugins

Smarty is not expiring or overwriting its compiled and cached templates


I am using Smarty (latest version v4.3.0) for my PHP project. is not expiring or overwriting its compiled and cached templates. I have explicitly defined a NO-CACHE behaviour. The code for that is:

// Smarty & configuration
$this->smarty = new Smarty();
$this->smarty->caching = Smarty::CACHING_OFF;
$this->smarty->template_dir = $this->_base_path . /app/templates/';
$this->smarty->compile_dir = $this->_base_path . '/app/templates/templates_c';
$this->smarty->config_dir = $this->_base_path . 
'/app/templates/config/';
$this->smarty->cache_dir = $this->_base_path . '/app/templates/cache/';

I've since removed it, but it had no affect. All my changes are being ignored. The first file that is created in my directory is the one that is not being overridden.

The directory permissions for the templates directory are: drwxrwxr-x www-data:root however the files being created in the directory are being created as follows:

-rw-r--r-- 1 www-data www-data  8585 Feb  6 21:29 8a59a03a5a13eaf28343fe9c9a076b3324d6ce8c_0.file.modal_calendar_event.tpl.php

How come my files cannot be overwritten? I am not seeing updated code as I push it.

I tried to add the following line (just to try and see if anything would update)

$this->smarty->clearAllCache();

But it doesn't even allow the compiled templates to be overridden.


Solution

  • Try setting $this->smarty->force_compile = true (docs)

    Also make sure the template files are really getting updated/pulled after your push and the output is not cached by any other system that would cause this behavior.