upgrader Posted May 31, 2009 Share Posted May 31, 2009 Hi there, I've never really done any caching at all so I'm looking for suggestions for caching the results of this script so that instead of it running everytime the page loads it only say once every hour. $html = file_get_contents('http://badhausen.hlstatsx.com/?mode=players&game=css'); $dom = new domDocument; $dom->loadHTML($html); $dom->preserveWhiteSpace = false; $x = new DomXPath($dom); $results = $x->query('//table/tr[position() >= 2 and position() <= 4]/td[2]/font/a'); foreach ($results as $result) { echo "<li>".$result->nodeValue."</li>\n"; } Quote Link to comment https://forums.phpfreaks.com/topic/160352-good-caching-method/ Share on other sites More sharing options...
anupamsaha Posted May 31, 2009 Share Posted May 31, 2009 Try do Google with "caching with php". Quote Link to comment https://forums.phpfreaks.com/topic/160352-good-caching-method/#findComment-846206 Share on other sites More sharing options...
dreamwest Posted May 31, 2009 Share Posted May 31, 2009 <FilesMatch "\.(css|js|swf|flv)$"> Header set Cache-Control "max-age=172800, private, proxy-revalidate" </FilesMatch> Quote Link to comment https://forums.phpfreaks.com/topic/160352-good-caching-method/#findComment-846217 Share on other sites More sharing options...
upgrader Posted May 31, 2009 Author Share Posted May 31, 2009 Try do Google with "caching with php". Thanks for your input... notice how I was asking for a good caching method in this situation... @dreamwest: what does that do etc? Could you explain it? Quote Link to comment https://forums.phpfreaks.com/topic/160352-good-caching-method/#findComment-846223 Share on other sites More sharing options...
dreamwest Posted May 31, 2009 Share Posted May 31, 2009 Try do Google with "caching with php". Thanks for your input... notice how I was asking for a good caching method in this situation... @dreamwest: what does that do etc? Could you explain it? It caches everything with the filesmatch extension. max-age is in seconds Quote Link to comment https://forums.phpfreaks.com/topic/160352-good-caching-method/#findComment-846226 Share on other sites More sharing options...
upgrader Posted May 31, 2009 Author Share Posted May 31, 2009 Hmmm, I don't really think that will work as that script above is part of a wordpress page so won't it screw that up? Can anyone else help? Quote Link to comment https://forums.phpfreaks.com/topic/160352-good-caching-method/#findComment-846237 Share on other sites More sharing options...
dreamwest Posted May 31, 2009 Share Posted May 31, 2009 It wont screw anything up. Add it to .htaccess file on your root directory. Quote Link to comment https://forums.phpfreaks.com/topic/160352-good-caching-method/#findComment-846248 Share on other sites More sharing options...
upgrader Posted May 31, 2009 Author Share Posted May 31, 2009 How does it work though? How does that cache the results from my script above? Quote Link to comment https://forums.phpfreaks.com/topic/160352-good-caching-method/#findComment-846354 Share on other sites More sharing options...
anupamsaha Posted May 31, 2009 Share Posted May 31, 2009 Try do Google with "caching with php". Thanks for your input... notice how I was asking for a good caching method in this situation... @dreamwest: what does that do etc? Could you explain it? Will Cache_lite help you? A good article is at: www.devshed.com/c/a/PHP/Caching-With-PHP-Cache-Lite Quote Link to comment https://forums.phpfreaks.com/topic/160352-good-caching-method/#findComment-846358 Share on other sites More sharing options...
dreamwest Posted June 1, 2009 Share Posted June 1, 2009 How does it work though? How does that cache the results from my script above? Itll cache any file, but not queries from a database Quote Link to comment https://forums.phpfreaks.com/topic/160352-good-caching-method/#findComment-846627 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.