In a simple PHP caching (with ob_start and files), I need parts (more -or equal- than 3 per page) where don’t caching (.PHP dynamic content or .PHP file context-user based).
+-----------------+
| CACHING CONTENT |
| |
+-----------------+
| NO CACHING |
+-----------------+
| CACHING CONTENT |
+-----------------+
| NO CACHING |
+-----------------+
| |
| CACHING CONTENT |
+-----------------+
In “no caching” parts I want include dynamic content. I can caching in three cached.html files (option 1), but I prefer have only one file per cached page (instead 3 pages, option 2). What is the best option for caching?
- Caching in several files (head_tag.html, body_part1.html, body_part2.html, body_part3.html…) and intermediate dynamic content (files.php).
- Caching to unique file, with some tag for replace with dynamic content (And… How?)
- Other
NOTE: Please, no third systems solutions (memcached, APC…). I need it from PHP-based option.
You can use placeholders for the non-caching parts of the page, and cache the whole page. For example, the whole cached page could look like:
Then in PHP, you would simply obtain this cached page and replace all placeholders with the dynamic content.
This way, you can place as many named placeholders as you like, for as many pieces of dynamic content as you like, then you simply replace them with the actual content.