phpapceacceleratoropcode-cache

Do I pay a performance penalty as PHP recompiles my source code for every request?


I know PHP is mostly an interpreted language. Does the PHP interpreter (php.exe in Windows and php file in Linux) do interpretation every time my script executes or only when I change the source? To put it another way, does the PHP interpreter cache interpreted scripts or not?


Solution

  • This is in essence what happens every time a request arrives:

    There is some overhead in compiling the file into opcode as many have already pointed out, and PHP by default has no cache, so it will do the "compilation" process every time a request arrives even if the file didn't change.

    There are some optional modules that can produce opcode caches to avoid that overhead, of which generally the most recommended is APC, since it will ship by default on PHP 6.