PHP OPcache 是否也缓存从 file_get_contents() 加载的文件?

Does PHP OPcache also cache the file load from file_get_contents()?

我无法在文档中找到问题的答案,也无法通过谷歌搜索几个小时。

本质上,这一切都归结为这段代码是否可以被OPcache缓存,包括json文件本身:

<?php
$array = json_decode(file_get_contents('./test.json'), true);

不,OPcache 只是在内存中缓存您预编译的脚本,因此 PHP 不需要在每次页面请求时读取和解析它。

您的代码结果,例如您的 file_get_contents() 调用的响应,不会被 OPcache 缓存。