0
votes

As you know, by default APC caches all files that server once compiled. I've got some question about caching:

  1. When should I really cache an entire file?

=======

  1. In the following code can I cache file1.php's opcode?
  2. Are every opcodes with the same values of variables are the same?

for example in file1.php, it has one variable and its value depends on user.

<?php
//connected to database and fetched the name of the user
$name = 'jack';
?>

Here is file2.php

<?php
include 'file1.php';
echo "hello Mr.".$userName;
?>
1
An opcode cache caches the opcode of a script, not the values of runtime variables - Mark Baker
So is it good idea to cache all the php files? - vandaad
If you want the speed benefits of opcode caching, then cache all the php files: only caching some is for exceptional circumstances (when working with some template engines for example), and is not normal use - Mark Baker

1 Answers

0
votes

When should I really cache an entire file?

Whenever you need it. To find out if you need it, you need to run metrics first.

The other two question let's just ignore until you've clarified for yourself what an opcode is (at least I suggest).