Hi, I am loading another web page (from a different server) using file_get_contents with a url for filename. Works well, but it isn't updating as that web page changes. I assume that the loaded page is being cached somewhere. How can I clear that cache, given that I have no control of the web page I am trying to load (and have no idea at which point the caching is being done!) ? Thanks.
PHP does cache some data for file access but it doesn't cache the contents of a file. You can try clearstatcache() but it really shouldn't work. That just leaves caching on the other server but if you browse to the site manually and get different content this also seems unlikely. Are you passing variables to the site in either GET or via a cookie? These may cause different versions of a page to be served to a browser.
You can try opening the file by sending a dummy random non-existent variable, like this: $url = 'http://example.com/file.html?r=' . rand(0, 9999); PHP: But as Streety said, I don't think PHP caches the contents of a file.
streety: Yes I already tried clearstatcache() in a vain hope: no good as expected! nico_swd (and streety): BRILLIANT! It worked. What a nice idea. Many many thanks. Pascua Feliz!
NetStar You really never understand the question, do you? Bouncing a 12 year old "solved" thread... Where is browser used in file_get_contents function call?
For whatever reason the thread was on the top when I replied. I think perhaps someone elses response was deleted. And of course I understand the question. He stated the web page content was NOT updating. The content is based off from the fetched page that was passed to the browser. Which means the caching "issue" was due to the browser viewing the content and NOT relating to the PHP function that retrieves the data. Genius.