$max_age) { //echo "unlinking ".getcwd()."/$file\n"; @unlink($file); } } } @closedir($handle); } chdir($start_dir); } function start_cache($max_age, $params=""){ $path = get_path($params); // check free disk space every once in a while if (!(rand() % CACHE_SIZE_CHECK_FREQ)) { $too_old=86400; while ((disk_free_space("../cache") < MIN_FREE_SPACE) || (disk_usage("../cache") > MAX_CACHE_USAGE)) { clean_cache($too_old, "../cache"); $too_old/=2; } } if ($max_age) { $request = getallheaders(); // Check to see if this is a conditional fetch. $lastmodified = @filemtime($path); $if_modified_since = isset($request['If-Modified-Since']) ? (explode(';',$request['If-Modified-Since'])) : false; if ($if_modified_since) { $if_modified_since=strtotime($if_modified_since[0]); } if ($if_modified_since && ($if_modified_since == $lastmodified)) { Header("Last-Modified: " . gmdate("D, d M Y H:i:s",$lastmodified) . " GMT"); Header('HTTP/1.0 304 Not Modified'); exit; } if ($lastmodified