Is it possible to cache only a specific part of a page in PHP, or the output of a specific section of code in the PHP script? It seems when I try to cache a particular page, it caches the whole page which is not want I want, some of the content in my page should be updated with every page load while others (such as a dropdown list with data from a database) only needs to be updated every hour or so.
Share
Zend_Cache
I would probably use Zend Frameworks
Zend_Cachelibrary for this.You can just use this component without needing to use the entire framework.
Step over to Zend Framework Download Page and grab the latest.
After you have downloaded the core files, you will need to include Zend_Cache in your project.
Zend_Cache docs.
Have you decided how you want to cache your data? Are you using a file system? Or are you memcache? Once you know which you are going to use, you need to use a specific Zend_Cache backend.
Zend_Cache Backends / Zend_Cache Frontends
Backend documentation: Zend_Cache Backends
Frontend documentation: Zend_Cache Frontends
So you would do something like this…
This would create a cache which makes use of the
Zend_Cache_Frontend_Outputcaching mechanisms.To use
Zend_Cache_Frontend_Outputwhich is want you want, it would be simple. Instead of the core you would useoutput. The options which you pass are identical. Then to use it you would:Zend_Cache_Frontend_Output – Usage
Useful Blog: http://perevodik.net/en/posts/14/
Sorry this question took longer to write than expected and lots of answers have been written I see!