time()) { $size = filesize($path); //########OUTPUT header("Content-Length: $size"); print "

CACHEEEEEEEEEE

"; $result = readfile($path); scrivo_statistiche(); exit(); //E FINISCE QUI } } function cache_in($output) { GLOBAL $DATI,$INRI; $file = $DATI[cache_dir]."/".cache_id($INRI); //controllo se l' md5 che ho in memoria e' lo stesso del file che devo sovrascrivere //se chiaramente c'e' un file con lo stesso nome e md5 //controolo esistenza file /* if(is_file($file)) { $md5_new = md5(file_get_contents($file)); $md5_old = md5($output); if($md5_new == $md5_old) { print "UGUALE"; return 0; } } */ //Sovrascrive il file perche e' cambiato //print "CAMBIATO"; $fp = fopen($file, "w"); fwrite($fp, $output, strlen($output)); fclose($fp); } function cache_eietto($buffer) { $size=strlen($buffer); //calcolo la data di ultima modifica setlocale(LC_TIME, "C"); clearstatcache(); // $ft = filemtime ('referencefile'); //metto tempo arbitrartio $ft = mktime(0, 0, 0, 12, 32, 2004); $localt = mktime (); $gmtt = gmmktime (); $ft = $ft - $gmtt + $localt; $modified = strftime ("%a, %d %b %Y %T GMT", $ft); //mando gli header giusti al posto del server web //header("Last-modified: Wed, 25 Apr 2001 17:17:08 GMT"); //header("HTTP/1.1 304 Not Modified"); //exit(); //header("Content-Length: $size"); //header("Last-Modified: $modified"); //d(apache_request_headers()); print $buffer; } ?>