I have finished two project with the vlibTemplateCache and I always have to explain the Designers what they have to to when they edit the Templates because of the Caching.
Yesterday when I cleaned my teath I've had an Idea: We can check if the Template was modified when we take a look at the modified filetime of the template (filemtime()) and compare it with the filetime of the cachefile. Today I started to make a closer look at the cache.php and i saw that you already was so clever to implement that. Then I started to make several Tests but it didn't work as I expected.
Now I want to explain the bug: (Sorry for my poor english i'm german)
cache.php:
...
_checkCache$tmplfile
...
// if it's expired
if filemtime$this-_cachefile + $this-OPTIONS'CACHE_LIFETIME' date'U'
|| filectime$this-_cachefile filemtime$tmplfile
$this-_cacheexists = 0;
return false; // so that we know to recache
Well this would be ok but
...
function _createCache$data
$f = fopen $cache_file, w;
// there you open the file and delete it.
...
touch $cache_file;
// now you change the 'last modified' time of the cachefile but the filectime of the cachfile is the same because the cachefile has already existed.
// But you check
filectime$this-_cachefile filemtime$tmplfile
and this is after the first modification of the template file always true and vlib never uses the cache. There's the problem. Either you delete the file bevor fopen or how i've solved the problem you check not the ctime, you check the mtime of the cachefile by
filemtime$this-_cachefile filemtime$tmplfile ... template file has modified so the cachefile is 'older' than the templatefile - recache. ...
With this codition in the if-clause it works great and i never need to recache() or clearCache().
I hope I've written all correctly and easy to understand.
mfg Andre
}