<?php
$file = "CACHE_DIR/$ID";
if (!file_exists("CACHE_DIR/$ID")) {
echo "<b>Load from server</b><br>\n";
$source = file_get_contents($url);
if ($source != "") {//cache
$f = fopen ($file, 'w');
fwrite($f, gzcompress($source, 9));
fclose($f);
}
} else {
$f = fopen ($file, 'r');
$source = gzuncompress(fread($f, filesize($file)));
fclose($f);
echo "<b>Load from cached file: <i>CACHE_DIR/$ID</i></b><br>\n";
}
// do something with source
?>
Title:
Using compress cached file by ID
Description:
<?php $file = "CACHE_DIR/$ID"; if (!file_exists("CACHE_DIR/$ID")) { echo "<b>Load from...
...
Rating:
4