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

eTags and View Output

We are playing with eTags for caching, and would like to use an MD5 of the page output as the eTag. So, my question is, how can I get the complete page output into a string, without changing the eventual display?

I tried doing this:

$eTag = md5(
    $this->view->render(
        'controller/view',
        array(
            '',
            '',
            '',
        )
    )
);
$this->response->setHeader('E-Tag', $eTag);

But it screws up my output by putting the views/index.volt twice into the browser.



15.1k
Accepted
answer

Found it!

For those who are interested:

$eTag = md5(
    $this->view->getRender('controller', 'view')
);