pane619
pane619

Reputation: 243

Does file_get_contents() use a cache?

If I write:

 $mypage=file_get_contents("www.mywebsite.com/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.

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?

Upvotes: 1

Views: 3132

Answers (1)

Anirudh Ramanathan
Anirudh Ramanathan

Reputation: 46728

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.

Upvotes: 3

Related Questions