Revision: 13823
Updated Code
at May 7, 2009 05:09 by jimmysessions
Updated Code
$url = 'http://...';
#we need to do some caching here
$cache_dir = dirname(__FILE__) . '/cache/'; // directory to store the cache
$cache_file = $cache_dir . md5($url);
$cache_time = 24 * 60 * 60; // time to cache file, # minutes * seconds
// check the cache_dir variable
if(is_dir($cache_dir) && is_writable($cache_dir) && file_exists($cache_file) && time() - $cache_time < filemtime($cache_file)){
$data = file_get_contents($cache_dir . md5($url)); // name of the cached file
} else {
$data = file_get_contents($url);
file_put_contents($cache_dir . md5($url),$data); //go ahead and cache the file
}
Revision: 13822
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 7, 2009 05:06 by jimmysessions
Initial Code
$url = 'http://...';
#we need to do some caching here
$cache_dir = dirname(__FILE__) . '/cache/'; // directory to store the cache
$cache_file = $cache_dir . md5($url);
$cache_time = 24 * 60 * 60; // time to cache file, # minutes * seconds
// check the cache_dir variable
if(is_dir($cache_dir) && is_writable($cache_dir) && file_exists($cache_file) && time() - $cache_time < filemtime($cache_file)){
$data = file_get_contents($cache_dir . md5($url)); // name of the cached file
} else {
$data = file_get_contents($url);
file_put_contents($cache_dir . md5($url),$dapper); //go ahead and cache the file
}
Initial URL
Initial Description
use this to cache a remote file with xml, json etc
Initial Title
PHP Remote File Cache
Initial Tags
php, cache, api
Initial Language
PHP