How to cache entire HTML output for certain module/controller/action?
EDIT: I'm talking about ZF application so caching should be with Zend_Cache.
Ok. There are some pages in my application that change very rarely. I would like to cache the whole HTML output so I don't need to do any PHP processing there. Is it possible?
Also, another problem. If there is a form on a page. I would lik开发者_开发技巧e the whole page to b taken from the cache first time but if a user submits the form, do not use cache anymore but process PHP.
Is that somehow possible?
I'm trying to figure some simple way to do this myself in the meantime.
use the Zend_Cache_Frontend_Page
If you take a look at this page, they explain how to setup it and use it. Regarding excluding dynamic content like forms etc, the feature let you choose which page are cached or not so with a bit of tweaking you should be ok.
If you don't want PHP processing (static file), you have to use Zend_Cache_Frontend_Capture and Zend_Cache_Backend_Static : http://framework.zend.com/manual/en/zend.cache.backends.html
However, it will not work with forms. In this case, you have to use Zend_Cache_Frontend_Page. This front end by default don't use cache when there are some variables in $_POST array (option cache_with_post_variables at false by default).
This is commonly referred to as "Output Caching."
Here's an informative article on the technique: http://www.devshed.com/c/a/PHP/Output-Caching-with-PHP/ .
In addition to answers already posted you can also use APC. APC (Alternative PHP Cache) is also commonly used to improve the performance by caching the byte code.
精彩评论