I have a system, which opens an external site inside it, but I have a small hitch; every time the page is accessed for the first time, the data obtained from the external page are not updated, they are saved in cache and stays forever, wanted to update this entire data made the page call the script responsible for opening the external page.
I pass the data by Javascript
to the file PHP
, the javascript
takes the url
of the news on the site, and sends through the GET
parameter to the script PHP
, which performs the opening of the site making use of the cURL
library.
The Script PHP
looks like this:
if(preg_match("#Politica#",$_GET['u'])){
$ir = $_GET['u'];
ob_start();
$cot = new ExibirPolitica();
$cot -> setUrlc($ir);
$cot -> printCot();
$conteudo = ob_get_contents();
ob_end_clean();
echo $conteudo;
}
The class ExibirPolitica();
contains only one cURL as follows:
$header = "X-Forwarded-For: {$_SERVER['REMOTE_ADDR']}";
$h2 = "Cache-Control: no-cache";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, "https://noticiando.com");
curl_setopt($ch, CURLOPT_HTTPHEADER, array($header,$h2));
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
$html = curl_exec($ch);
As you can see, I tried to use ob_end_clean();
and print the content below to see if it was updated, I also tried " no-cache"
no cURL
, also unsuccessful!"
Is there any way to "force" the update of content obtained by cURL
?