Theo
Theo

Reputation: 2792

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

I was not able to find an answer to my question in the docs or by a few hours of googling.

Essentially, it all boils down to whether this code can be cached by OPcache including the json file itself:

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

Upvotes: 0

Views: 972

Answers (1)

Juri Salminen
Juri Salminen

Reputation: 151

No, OPcache is only caching you precompiled script in memory so PHP does not need to read and parse it on every page request.

The result of your code, like the response of your file_get_contents()-call, is not cached by OPcache.

Upvotes: 2

Related Questions