look up the "output buffering" functions, such as ob_start, and ob_flush. You can do the following.
At the top of your pages you check for a cache-file that is less than X minutes old (perhaps 10). If one exists, you just do a readfile(foo) and exit() [where foo is the cachefile name]. if one doesn't exist, you call ob_start.
Then at the end of the page you write the output buffer to a file and then flush the buffer to the user.
An easy way to generate the names of the cache-files is to take the REQUEST_URI and replace all the /'"?#@$%&*()![]{};:<,>`~ with a . (or something). You can check how old a file is with the filemtime function.
-andy