I am using PHP Simple HTML DOM Parser and using $html->load_file
include('simple_html_dom.php');
$html = new simple_html_dom();
$html->load_file('https://www.google.com/finance?q=goog');
the link below demonstrates a method to force caching of the content. I need to retrieve pages where the content changes depending on the last part of the url. Is it possible to modify the code below to force caching, for example, if I retrieve the following pages:
google.com/finance?q=goog
google.com/finance?q=wwwfx
google.com/finance?q=vigrx
Can I cache each one of those pages until the end of the session because I will need the page content repeatedly.
Caching PHP Simple HTML DOM Parser
function cache_get_contents($url, $offset = 600, $override = false) {
$file = '/tmp/file_cache_' . md5($url);
if (!$override && file_exists($file) && filemtime($file) > time() - $offset)
return file_get_contents($file);
$contents = file_get_contents($url);
if ($contents === false)
return false;
file_put_contents($file, $contents);
return $contents;
}