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.

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.



9.0k
Accepted
answer

Found it!

For those who are interested:

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