I have a PHP cURL request which gets another page on my domain. The page which is being retrieved has linked files such as .css. When I update one of the .css files and upload it to the domain, then request the same page again, it returns the same version of the .css file with none of the updates that I just did. I then check the linked file on the domain to see if it was uploaded ok (which it is) and the url of the linked file in the returned page (which is pointing to the correct file).
I have even deleted all temp browser files to force it to look for a new version of the linked files, but it didn’t make a difference.
The request is completed successfully and there are no errors. I think it may be from cache or something like that. After an hour or so, when the page is requested again, the correct version of the .css file is returned within the returned page.
My cURL Request is the following:
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $host . $requestURL);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl_handle, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($curl_handle, CURLOPT_FRESH_CONNECT, TRUE);
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($curl_handle, CURLOPT_MAXREDIRS, 10);
curl_setopt($curl_handle, CURLOPT_DNS_USE_GLOBAL_CACHE, FALSE);
curl_setopt($curl_handle, CURLOPT_FORBID_REUSE, TRUE);
$content = curl_exec($curl_handle);
curl_close($curl_handle);
echo $content;
This has really confused me as i can’t seem to “force” get the latest version of a linked file.
Any ideas will be awesome!
The problem is that you’re getting a cached copy of the css file. I believe there’s a header you can use to fix this, but if you don’t want to do that, add something like
whatever.css?x=$randomto the URL you’re requesting to hard force a new pull of the file. Not the best way, but it’ll likely work.