To minimize page loading time, we are caching our PHP generated HTML as an HTML file. If a "cache file" exists we use it. Otherwise we run the PHP scripts to generate the page. To reduce the page loading speed even more, we would like to remove the "If file exists" line (which takes time) and simply let PHP generate an error if the file does not exist. We would then "catch" the error and let PHP generate the page.
The question is the following: Is there a simple way to implement "On error, leave function" in PHP.
This is the code we have:
function UseCachedPage()
{
$CacheFile='mypage.html';
if(!file_exists($CacheFile)) return; //Would like to skip this to save time
include($CacheFile);
//Magic "on error, leave function" needed here.
exit; //Cache included, so no need to run the php.
}
Any help would be appreciated.