We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Cache doesn't work

hi

I try to cache a part of my view but, apparently, it is not working


<!-- partials\footer -->

    {% cache "footer" 3600 %}
        <div id="footerSt">

        <!-- some html here -->

        </div><!-- div#footerSt -->

    {% endcache %}

in the cache file there is only so

N;

I'm using xcache 3.2, but with the file adapter was the same

what can it be?

phalcon 1.3.3 php 5.5 apache 2.4

sorry for my english



98.9k

How are you setting up the 'viewCache' service?

yes


use \Phalcon\Cache\Frontend\Data as PhCacheFront;
//use \Phalcon\Cache\Backend\File as PhCacheBack; // dont't works too
use \Phalcon\Cache\Backend\Xcache as PhCacheBack;

$di = new \Phalcon\DI\FactoryDefault();

$config = $di->get('config');

$di->set('viewCache', function () use ($config) {
        // Get the parameters
        $lifetime        = $config->cache->lifetime;
        $frontEndOptions = array('lifetime' => $lifetime);

        $frontCache = new PhCacheFront($frontEndOptions);
        $cache      = new PhCacheBack($frontCache, $backEndOptions);

        return $cache;
});

any html data is not cached

when it is not html, works



98.9k
Accepted
answer

You have to use the Output frontend:

use \Phalcon\Cache\Frontend\Output as PhCacheFront;

thanks so much

You have to use the Output frontend:

use \Phalcon\Cache\Frontend\Output as PhCacheFront;