PHP caching is easy. Here is how it's done:
Code:
<?php
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>x10 Status</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
Some dynamic sitecontent to be cached here please
</body>
</html>
<?php
$buffer = ob_get_contents();
ob_end_flush();
$fp = fopen('./cache/content.cache','w');
fwrite($fp,$buffer);
fclose($fp);
?>
What you need to do here:
Create a folder called "cache", in this folder, create a file called content.cache.
Now create the file to be cached with the code up there ^.
Now create index.php, in this file, write:
Code:
<?php
if (file_exists('./cache/content.cache'))
{
readfile('./cache/content.cache');
exit();
}
else {
echo "FAIL";
}
?>
Also, chmod the cache folder to 777.
First, when you visit index.php, it gonna be blank. now run the file that should get cached, containing the first code. Visit index.php again and you will see it work.
Now if you want, run a cron on the file with the dynamic content. This is good for scripts that check the status of a server etc.