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 views and flashSession: Workflow

What should be the workflow for caching views containing flashSession? I think we have to disable the cache if there is a flashSession.



40.1k
Accepted
answer

I think this code behaves well:

if (!$this->flashSession->has()) {
        if ($this->request->isGet()) {
            $this->view->cache(
                array(
                    "lifetime" => 3600,
                    "key" => $cacheKey
                )
            );
        }
    }