note 95585 added to function.filemtime

From: Date: Mon, 11 Jan 2010 07:01:11 +0000
Subject: note 95585 added to function.filemtime
Groups: php.notes 
Request: Send a blank email to php-notes+get-164838@lists.php.net to get a copy of this message
Cheap and dirty way to code a cache: <?php $cache_file = 'URI to cache file'; $cache_life = '120'; //caching time, in seconds if (!file_exists($cache_file) or (time() - filemtime($cache_file) >= $cache_life)){ ob_start(); resource_consuming_function(); file_put_contents($cache_file,ob_get_flush()); }else{ readfile($cache_file); } ?> ---- Server IP: 130.206.1.5 Probable Submitter: 85.136.137.29 ---- Manual Page -- http://www.php.net/manual/en/function.filemtime.php Edit -- https://master.php.net/note/edit/95585 Del: integrated -- https://master.php.net/note/delete/95585/integrated Del: useless -- https://master.php.net/note/delete/95585/useless Del: bad code -- https://master.php.net/note/delete/95585/bad+code Del: spam -- https://master.php.net/note/delete/95585/spam Del: non-english -- https://master.php.net/note/delete/95585/non-english Del: in docs -- https://master.php.net/note/delete/95585/in+docs Del: other reasons-- https://master.php.net/note/delete/95585 Reject -- https://master.php.net/note/reject/95585 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#164838) next »