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.

cache not expirable: lifetime

How I can set a cache file without expiration?

'lifetime' => -1

Is zero for never expire?? or -1??


0, remember to set it both for frontend and backend.

@Wojciech should this work with modelsCache as well? I've tested but no success. Here is old topic of mine with example:

I debug with xdebug and not work!.

tested with File backend and None Frontend:

if !lifetime {
                let lastLifetime = this->_lastLifetime;
                if !lastLifetime {
                    let ttl = (int) frontend->getLifeTime();
                } else {
                    let ttl = (int) lastLifetime;
            } else {
                let ttl = (int) lifetime;

            clearstatcache(true, cacheFile);
            let modifiedTime = (int) filemtime(cacheFile);

             * Check if the file has expired
             * The content is only retrieved if the content has not expired
if modifiedTime + ttl > time() {


The lifetime is used when files are retrieved. The oldest modified time is 0. The maximum time is either a 32 bit integer, something like year 2032, or a 64 bit integer. In a 64 bit system, you can set the lifetime to mktime(0, 0, 0, 0, 0, 5000) or to time()*10.