soroush.r70
چهارشنبه 18 مرداد 1391, 13:18 عصر
من یه اسکریپت برای کش کردن وب سایت گیر اوردم دوستان می تونن یه توضیح در مورد این اسکریپت و اینکه این فایلی که در این اسکریپت در پوشه cache وجود دارد در واقع چی هست و چطوری باید ازش استفاده کرد..؟
<?php
....
$cacheFile=$_SERVER['DOCUMENT_ROOT']."/cache/id".$_GET["id"].".html";
if (file_exists($cacheFile)) //we can read this cache file back reduce database load
{
header("Content-Type: text/html");
readfile($cacheFile);
exit;
} else {
ob_start(); //start buffering so we can cache for future accesses
}
...
?>
<html><body>
DO THE HTML RENDERING HERE
</body></html>
<?php
// get the buffer
$buffer = ob_get_contents();
// end output buffering, the buffer content
// is sent to the client
ob_end_flush();
// now we create the cache file
$fp = fopen($cacheFile, "w");
fwrite($fp, $buffer);
fclose($fp);
?>
در ضمن آیا اسکریپت مفیدی می تونه باشه یا نه...؟
<?php
....
$cacheFile=$_SERVER['DOCUMENT_ROOT']."/cache/id".$_GET["id"].".html";
if (file_exists($cacheFile)) //we can read this cache file back reduce database load
{
header("Content-Type: text/html");
readfile($cacheFile);
exit;
} else {
ob_start(); //start buffering so we can cache for future accesses
}
...
?>
<html><body>
DO THE HTML RENDERING HERE
</body></html>
<?php
// get the buffer
$buffer = ob_get_contents();
// end output buffering, the buffer content
// is sent to the client
ob_end_flush();
// now we create the cache file
$fp = fopen($cacheFile, "w");
fwrite($fp, $buffer);
fclose($fp);
?>
در ضمن آیا اسکریپت مفیدی می تونه باشه یا نه...؟