php caching problem

MrScott81

Golden Member
Aug 31, 2001
1,891
0
76
So I have a php page that I use to grab NFL scores for a family football pool that I run.

I previously used to web scrap an ESPN website but they changed their format and I sought an easier approach. I finally ended up finding a nice little xml file provided by nfl.com that is very minimal and contains all of the information I need.

Example url:
http://www.nfl.com/ajax/scorestrip?season=2015&seasonType=REG&week=15

This xml file gets updated in near real time and is perfect, except for one minor problem that I'm running into and that's the fact that I keep getting cached results. The ONLY way that I have been able to get around this is by setting up a cron job to use wget to download the file every X amount of minutes and have my php parse the downloaded file.

Things I have tried that DO NOT work:
1) Adding a dummy variable to the URL I am trying to scrape from to have a "unique" url. Example:
http://www.nfl.com/ajax/scorestrip?season=2015&seasonType=REG&week=15&dummy=1923751975

2) Using php to call exec which runs a wget command (same command that I setup in the cron job). For some reason, this still gets the cached result.

3) All sorts of php header variables to try to prevent caching.

Here's a code snippet of my stuff:
Code:
<?php
header("Content-type: text/xml");
header("Cache-Control: max-age=0, no-cache, no-store, must-revalidate");
header("Pragma: no-cache");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: Sat, 26 Jul 1997 05:00:00 GMT");

$url = "http://www.nfl.com/ajax/scorestrip?season=".
			$year."&seasonType=REG&week=".$week."&dummy=".time();
$xml = simplexml_load_file($url);

Any suggestions would be appreciated.
 

uclabachelor

Senior member
Nov 9, 2009
448
0
71
The headers affect requests between the end client (your browser) and your php server, not between your server and the third party url.

Anyhoo, afaik, PHP doesn't provide any caching for HTTP downloads or data retrieved from streams so any caching issues that you're encountering is either on your ISP end, browser end, or third party server's end unless you've installed a server module that caches key-value pairs.

What's the output of phpinfo(); ?

Also, why do you think the results are "cached" ?

And lastly, if you do a wget <url> twice 5 minutes apart, what SHOULD the difference be between the two result sets?
 
Last edited:

petyr_

Junior Member
Dec 28, 2015
12
0
0
Can you print your phpinfo(); here?

EDIT: uclabachelor already requested it, sorry!
 

MrScott81

Golden Member
Aug 31, 2001
1,891
0
76
Please disregard this thread, I'm an idiot. It turns out the file was not getting overwritten because of permissions problems. Cron worked because I had it running under root.

Sometimes I feel so stupid
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |