file_get_contents()是否使用缓存? [英] Does file_get_contents() use a cache?

查看:287
本文介绍了file_get_contents()是否使用缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我写:

 $mypage=file_get_contents("www.mywebsite.com/mypage.htm");

第一次运行脚本时,file_get_contents()肯定会向www.mywebsite发出HTTP请求.com for mypage.htm,并获得mypage.htm内容的回复。

The first time I run the script, file_get_contents() will surely make a HTTP request to www.mywebsite.com for mypage.htm, and get a response with the content of mypage.htm.

但是每次下次运行脚本时,file_get_contents()都会得到真实的在www.mywebsite.com上提交文件?
或者它在localhost上有某种缓存?

But every next time I run the script, will file_get_contents() get the real file on www.mywebsite.com? Or it has some kind of cache on the localhost?

推荐答案

。但是,由于DNS记录由服务器的操作系统缓存,因此 DNS解析步骤可能会在后续尝试中更快(直到缓存条目到期),因此会加速。

It does not. However, there will be a speed-up because the DNS resolution step may be faster on subsequent tries (till the cached entry expires), as the DNS records are cached by the server's OS.

这篇关于file_get_contents()是否使用缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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