When considering a suitable caching system, I wanted it to be simple and fast, without compromising information integrity by displaying outdated website content.
As index.php and the front-end architecture diagram show, Cache.php is loaded before the application. If a cache check succeeds, the system exits without loading the application.
if($cache->isCached()){
$cache->response($cache->buffer);
exit;
}
If the resource is not cached, the page must be processed to produce the response. The resulting response is then cached to avoid processing it again on the next request.
$cache->set($buffer);
If the resource is not cached, the page must be processed to produce the response, and the newly requested resource is then saved.