Peter Peter - 1 year ago 90
PHP Question

PHP and Smarty compile delay after upgrading system

After upgrading my Xubuntu from 13.04 to 13.10 I am experiencing issue error with Smarty and PHP.

Basically Smarty templates are recompiled with 5-7 seconds delay after I edit template.

I compared system time (

) with PHP's
and timestamp is equal.

PHP Version 5.5.3-1ubuntu2

How to fix it?

Example code:

require_once 'classes/Smarty-3.1.8/libs/Smarty.class.php';

$tpl = new Smarty();
// if I edit this template, changes shows up after
// 3-4 seconds which is very annoying
// there was no issue in xubuntu 13.04 / older php version!


I double checked is
working properly and it is.

Answer Source

You can keep opcache enabled and set:


The problem is that by default opcache only checks timestamps after 2 seconds, and the smarty compiled templates are generated during the same request so are not checked.

Setting opcache revalidate_freq to 0 makes opcache check timestamps for all files every time, so changes made in .tpl files show instantly.

Edit: I believe this is no longer necessary as of Smarty v3.1.29

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download