0
I have a system, which opens an external site inside it, only I have a small obstacle; every time the page is accessed for the first time, the data obtained from the external page are not updated, they are cached and stay forever, wanted to update this whole data made the page call the script responsible for opening the external page.
I pass the dice by Javascript
to the archive PHP
, the javascript
picks up the url
of the news on the site, and send through the parameter GET
to the script PHP
, that carries out the opening of the site making use of the library cURL
.
The Script PHP
is 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 the ob_end_clean();
and print the content below to see if it came updated, also tried the "no-cache"
in the cURL
, also unsuccessful!
Is there any way to "force" the update of a content obtained by cURL
?
Thank you Rodrigo! gave right to suggestion 1.
– Cassiano José