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

Conditional volt view cache

Hi my friends,

I want to start cache in view with some conditions (such as logged in user or not), but with no success!

1. {% if logged_in %}
2.   {% cache "my-page" %}
3. {% endif %}


Syntax error, unexpected token ENDIF in /var/www/testvolt/app/views/index/vip.volt on line 3

Is it possible to use conditional view cache anymore?


Thank you for your reply.

I already know how to cach view in controller but I think caching views in controller is not MVC-oriented.

I think the view layer should have such conditional enable/disable cach functionality


Hi guys,

I think that you would use https://docs.phalcon.io/en/latest/reference/views.html#using-partials and https://docs.phalcon.io/en/latest/reference/views.html#caching-view-fragments