ZF-8867: Page cache doesn't work from the controller.

Description

I have initialized the page cache in the controller's action method. Not sure if it's a wrong place to create and start the page cache, but the result is that empty page is cached and after first attempt the page becomes empty.

I did some debugging and it looks like the problem comes from the point that the cache's _flush method is called and the data is cached at wrong time when the buffer is already cleared up with the ViewRenderer action helper in its render method, there the ob_start and ob_end_clean are called, which I think causes the problem.

Comments

After some debugging I found that the Page cache was not working because of the output buffering in the frontcontroller. If I set the ini parameter resources.frontcontroller.params.disableOutputBuffering=true to disable the output buffering, everything works fine.

Is this the correct behaviour? Or is this still an issue that will be fixed?

Hi Aram,

It's the correct behaviour but was never documented. I'll update the documentation now to clarify this (it puzzled me too for a while ;)). But yes, we need to disable the output buffering performed when dispatching the request. On the other hand, it doesn't seem to do an awful lot anyway so its harmless to disable.

Note added to documentation in r20712