I have follow PHP action:
public function bookAction() {
$googleId = $this->dispatcher->getParam('googleId', 'string');
$cacheKey = $googleId.'.png';
if ($this->view->getCache()->exists($cacheKey)) {
echo $this->viewCache->get($cacheKey);
return false;
}
$image = $this->helpers->curlRequest('https://qwe.com');
$this->view->cache(array(
'key' => $cacheKey,
));
$this->response->setHeader('Content-Type', 'image/png');
return $this->response->setContent($image);
}
And cache service:
$di->set('viewCache', function () use ($di) {
$cache = new Phalcon\Cache\Backend\File(
new Phalcon\Cache\Frontend\Output(array(
'lifetime' => 2592000,
)),
array(
'cacheDir' => '../app/cache/pages/',
)
);
return $cache;
});
When there is no output (as in this case), phalcon does not cache the output.
(p.s. this code works fine when there is output)
Any ideas?