Skip to content

Instantly share code, notes, and snippets.

@jessedc
Created July 5, 2010 12:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessedc/464297 to your computer and use it in GitHub Desktop.
Save jessedc/464297 to your computer and use it in GitHub Desktop.
$cacheDir = './cache/';
$curl_setopt_array = array( CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true);
if (file_exists($cacheDir.$filename)) {
$timetable_view_file = file_get_contents($cacheDir.$filename);
}else{
$curlR = curl_init($request_url);
if (curl_setopt_array($curlR, $curl_setopt_array)){
$timetable_view_file = curl_exec($curlR);
//save new found file to disk, it's kept in memory too.
file_put_contents($cacheDir.$filename,$timetable_view_file);
curl_close($curlR);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment