有没有办法告诉curl不使用缓存 [英] Is there a way to tell curl to not use cache

查看:4540
本文介绍了有没有办法告诉curl不使用缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要找出网址的档案大小:

  $ url1 ='www.google.com'; 
$ curl1 = curl_init();
curl_setopt($ curl1,CURLOPT_URL,$ url1);
curl_setopt($ curl1,CURLOPT_RETURNTRANSFER,TRUE);
curl_exec($ curl1);
$ file_size = curl_getinfo($ curl1,CURLINFO_SIZE_DOWNLOAD);
$ file_size_kb = $ file_size / 1000;
echo $ file_size_kb;

输出 43331 。我认为它太低,因为我有google缓存。这是真的吗?

解决方案

你可以使用

code> CURLOPT_FRESH_CONNECT 为此。从 curl_setopt



CURLOPT_FRESH_CONNECT TRUE可强制使用新的连接, >



  curl_setopt($ curl1,CURLOPT_FRESH_CONNECT,TRUE); 


I am trying to find out file size of an url:

$url1 = 'www.google.com';
$curl1 = curl_init();
curl_setopt($curl1, CURLOPT_URL, $url1); 
curl_setopt($curl1, CURLOPT_RETURNTRANSFER, TRUE);
curl_exec($curl1);
$file_size = curl_getinfo($curl1, CURLINFO_SIZE_DOWNLOAD ); 
$file_size_kb = $file_size / 1000;
echo $file_size_kb;

The output is 43331. I think its too low because i have google cached. Can this be true? Also i tested google on some other site that calculates size of url, and it was twice as big.

解决方案

You can use CURLOPT_FRESH_CONNECT for this. From curl_setopt

CURLOPT_FRESH_CONNECT TRUE to force the use of a new connection instead of a cached one.

curl_setopt($curl1, CURLOPT_FRESH_CONNECT, TRUE);

这篇关于有没有办法告诉curl不使用缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆