Symmetry Posted May 18, 2008 Share Posted May 18, 2008 Here's my dilemma.. I'm trying to load a page from wikipedia with file_get_contents() and it seems to be loading an older version of the page and I'm not sure how to conquer this.. so how would I do it with PHP (or HTML?) so that I get the freshest page? Here's the timestamp of the page php's loading: <!-- Saved in parser cache with key enwiki:pcache:idhash:12762141-0!1!0!default!!en!2 and timestamp 20080516003812 --> and the page when I go to it in the browser: <!-- Saved in parser cache with key enwiki:pcache:idhash:12762141-0!1!0!default!!en!2 and timestamp 20080518020756 --> As you can see one is from the 16th, and the other is from the 18th. Thank you for assistance. Link to comment https://forums.phpfreaks.com/topic/106238-page-cached-trying-to-get-a-page-with-file_get_contents/ Share on other sites More sharing options...
realjumper Posted May 18, 2008 Share Posted May 18, 2008 At the top of your page..... <?php header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past ?> Link to comment https://forums.phpfreaks.com/topic/106238-page-cached-trying-to-get-a-page-with-file_get_contents/#findComment-544504 Share on other sites More sharing options...
Symmetry Posted May 18, 2008 Author Share Posted May 18, 2008 Thank you.. the time stamp now reads <!-- Saved in parser cache with key enwiki:pcache:idhash:12762141-0!1!0!default!!en!2 and timestamp 20080518020756 --> The current date, but it's still giving me issues as it's not the same page.. I'm confused. Here's the code I'm using: <?php header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past $file = file_get_contents("http://en.wikipedia.org/wiki/Category:Undrafted_National_Football_League_players"); echo $file; ?> Maybe someone can try the code and see if it produces the same results for them, for me the last name on the page with file_get_contents() is Marques Douglas, when I goto the url via browser it's Robert Douglas (American football) ??? Link to comment https://forums.phpfreaks.com/topic/106238-page-cached-trying-to-get-a-page-with-file_get_contents/#findComment-544511 Share on other sites More sharing options...
realjumper Posted May 19, 2008 Share Posted May 19, 2008 Oh I see what you mean now. The code I gave you will ensure that the page you are viewing will not come from the cache.......but it won't make a difference to the linked file you are getting. Sorry, my mistake. Not sure how to combat that issue you have Link to comment https://forums.phpfreaks.com/topic/106238-page-cached-trying-to-get-a-page-with-file_get_contents/#findComment-544513 Share on other sites More sharing options...
Symmetry Posted May 19, 2008 Author Share Posted May 19, 2008 Yeah it is kinda baffling me, ty for helping though. Link to comment https://forums.phpfreaks.com/topic/106238-page-cached-trying-to-get-a-page-with-file_get_contents/#findComment-544516 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.