curl ..でURLを指定し、ヘッダー属性Expiresに基づいてそれをフェッチしたいと思います。
過去30日間にキャッシュされた場合にのみ、ページを取得したい。
私が正しくないと思う2つのこと...
1)gmmktime(0、0、0、1、1、1998)..今日に設定する方法がわかりません-30日前。2)ヘッダーに基づいてグーグルを返すかどうか?URLに30日より古い日付のキャッシュされたヘッダーがない場合の$page変数はどうなりますか
function exractURl()
{
//How to convert gmmktime to the last 30 days from today
$ts = gmdate("D, d M Y H:i:s", gmmktime(0, 0, 0, 1, 1, 1998)) . " GMT";
$c= curl_init('http://www.google.co.il/');
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_HTTPHEADER, array('Expires:'.$ts));
// What output will page give me..if the headers arent found
$page= curl_exec($c);
curl_close($c);
}
アップデート:
function exractURl()
{
$ts = gmdate("D, d M Y H:i:s", strtotime("30 days ago")) . " GMT";
$c= curl_init('http://www.google.co.il/');
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_HTTPHEADER, array('If-Modified-Since:'.$ts));
$page= curl_exec($c);
curl_close($c);
return $page;
}