What is the best PHP cache whole page class? #cache whole page
Edit
by Mpho Moipolai - 8 years ago (2016-09-07)
Cache the whole Web page
| I want to cache whole Web pages with a cache script thats not complicated. |
Ask clarification
2 Recommendations
AhCache: Store cached data in files
This class can store cached data in files.
It can check if a given cache file exists and it has not passed more than a given expiry time. The class checks the last modified timestamp to determine if the cache file is expired.
In that case the class can retrieve the cached data. Otherwise the class can store the cache data in a file for a given expiry period.
The cache directory is derived from the cache ID value. The class can create sub-directories to reduce the number of cache files per directory.
The class can also delete individual cache files, all cached files about a given age of one or all modules.
| by Axel Hahn package author 35 - 8 years ago (2016-09-11) Comment
The ahcache class stores all items that can be serialized (integer, string, arrays, ...). Its main usage is to store a cache for a functionality that was identified as a slow component (with long running queries, fetching external content like rss feed from other websites).
To identify outdated content you can use a TTL, or read the age or compare with a file. Cleaning up the cache directory is included too.
Using a php class for caching means: you need to touch the source code.
If you don't want to touch any code and have the possibility then use caching modules like mod_cache in apache/ proxy_cache in nginx or a separate caching host, i.e. varnish. |
AC full page cache: Capture and cache the output of whole page scripts
This class can capture and cache the output of whole page scripts.
It can check if the current page script cache file exists and is up to date. If it is, it outputs the contents of the cache file.
Otherwise it starts capturing the script output and registers a PHP shutdown function that will retrieve the captured output and stores it in the cache file when the script exits.
| by Manuel Lemos 26695 - 8 years ago (2016-09-08) Comment
You may want to try this class. It can start capturing the page output in the beginning and output it using a registered shutdown function, so you do not need to change much your scripts to cache your pages output. |