Caching output in PHP
Caching output in PHP
Caching of output in PHP is made easier by the use of the output buffering functions built in to PHP 4 and above.
You’ll need to use two files to set up a caching system for your site. The first, “begin_caching.php” in this case, will run before any other PHP on your site. The second, “end_caching.php” in this case, runs after normal scripts have run. The two scripts effectively wrap around your current site.
This is done by adding the following two lines of code to your htaccess file.
1. php_value auto_prepend_file /full/path/begin_caching.php
2. php_value auto_append_file /full/path/end_caching.php
