Let's say that I force mod_php to take in .html
files. Let's say that there's 0 PHP code in one of these files.
If I browse to that file with APC enabled, what happens? Does it get cached or does it still have to be read from the disk?
The other scenario, I have a .php
file. What happens to the content outside PHP tags? Does it get stored in memory? Or does it have to be read from the disk every time?
If I browse to that file with APC enabled, what happens? Does it get cached or does it still have to be read from the disk?
If you have .html
files set to be parsed as PHP, then yes -- it will be cached. Sort of.
Specifically, PHP will generate an optree for the document, which ends up being a very short and boring program with a single very large string constant in it. This will end up getting stored in memory. HOWEVER, if that's all you're after, you'd be much better off using something like mod_mem_cache
(unrelated to memcached!) instead, as it's actually designed to cache static content.
The other scenario, I have a .php file. What happens to the content outside PHP tags? Does it get stored in memory? Or does it have to be read from the disk every time?
As I alluded to earlier, content outside PHP tags is still treated as part of the PHP "program" -- although it's treated a little differently internally, a chunk of static text surrounded by ?> ... <?php
(or at the beginning or end of a file) is effectively treated as if it were in an echo "..."
. (Except without all the gotchas involving escaping within that string.) For instance, the following two code blocks are functionally more or less identical, other than some differences in whitespace:
<?php
if ($condition) {
echo "Hello";
}
?>
vs.
<?php if ($condition) { ?>
Hello
<?php } ?>