Force file_get_contents to get fresh copy of remote file
Posted: Mon Mar 23, 2009 4:04 pm
I'm using file_get_contents to retrieve a SWF file on a remote server. The purpose of the script
is to compare the contents of the SWF on "Server A" to the contents of the SWF on "Server B".
If the files differ, the file gets copied from "Server A" to "Server B".
The problem is that the server running the PHP script appears to be retrieving a cached version
of the SWF file. That is, the PHP script says the files are the same, but if my neighbor or I view
the URLs in our browsers, the files are different.
This happens intermittently, and I'm not sure how to tell file_get_contents to pull a fresh, un-cached
SWF from "Server A", or how to clear any sort of cache the PHP server may be maintaining separately.
This happens for images as well.
I am not bound to file_get_contents. I can use some other mechanism for retrieval if it will resolve
this problem.
Does anybody have any suggestions?
is to compare the contents of the SWF on "Server A" to the contents of the SWF on "Server B".
If the files differ, the file gets copied from "Server A" to "Server B".
The problem is that the server running the PHP script appears to be retrieving a cached version
of the SWF file. That is, the PHP script says the files are the same, but if my neighbor or I view
the URLs in our browsers, the files are different.
This happens intermittently, and I'm not sure how to tell file_get_contents to pull a fresh, un-cached
SWF from "Server A", or how to clear any sort of cache the PHP server may be maintaining separately.
This happens for images as well.
Code: Select all
if ( file_get_contents($urlA) == file_get_contents($urlB) )
{
return false; // no change detected in files
}
this problem.
Does anybody have any suggestions?