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 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



85.4k

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



85.4k
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;