其实我有两个问题.
(1)如果我只检索标题而不是使用php和curl进行完整页面检索,那么远程服务器上使用的处理能力或带宽是否会减少?
(2)由于我认为,我可能错了,第一个问题的答案是肯定的,我试图获取最后修改日期或If-Modified-Since标题的远程文件只是为了将它与时间日期进行比较本地存储的数据,所以我可以,如果它已被更改,将其存储在本地.但是,NULL当我运行这个时,我的脚本似乎无法获取那条信息:
class last_change {
public last_change;
function set_last_change() {
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://url/file.xml");
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_FILETIME, true);
curl_setopt($curl, CURLOPT_NOBODY, true);
// $header = curl_exec($curl);
$this -> last_change = curl_getinfo($header);
curl_close($curl);
}
function get_last_change() {
return $this -> last_change['datetime']; // I have tested with Last-Modified & If-Modified-Since to no avail
}
}
Run Code Online (Sandbox Code Playgroud)
如果$header = curl_exec($curl)未启用,即使我没有请求它,也会显示标题数据,如下所示:
HTTP/1.1 200 OK
Date: Fri, 04 Sep 2009 12:15:51 GMT …Run Code Online (Sandbox Code Playgroud) 使用Rails 3,有没有办法在模型中使用link_to helper或任何帮助器?