I'm somewhat a new comer to programming and am getting lots of question about data caching. Say, there exists a bit of static content. What's destined to be faster: save this content right into a phphtml file and output the page out of the box, or make use of a script which will output this content via apc_fetch() (trained with was formerly held in memory)? Within the first situation Apache will invariably browse the page in the file system also it never keeps pages in RAM, doesn' it? Does current APC implementation fully trust FastCGI? Thanks ahead of time!

I'm still not receiving why do benchmarks show a quadruple speed-up when utilizing APC caching in comparison to presenting the file system, while Apache can load static pages so quick.

Instead of cache the whole page statically, I'd cache the various components which are dynamic on that page (database calls etc) then either make use of the file system or memcache to keep individuals cache results.

Writing out static pages can get harder to keep because the site develops, and will also be more overhead in case your repairing pages more often.

Static HTML will be the quickest. Despite opcode caching, PHP will still need to load and run the script, visit the cache, etc. Apache's primary purpose, however, would be to serve static content as quickly as possible and it is enhanced to do this.

In case your webserver needed to fetch every content item from disk then it might be unbelievably slow. All modern Os's implement sophisticated disk caching.

save this content right into a phphtml file and output the page out of the box, or make use of a script which will output this content via apc_fetch()

Being able to access a static file (i.e. not really a PHP file) is going to be much, considerably faster, than being able to access a PHP file, parsing the PHP, then performing the PHP to call apc_fetch(). Whether it might be faster to create an html page from PHP, or use PHP to retrieve the produced is a result of APC, the solution will rely on just how much effort the PHP needs to do

I'd expect....

<?php
 print "hello world";
?>

Is going to be faster than

<?php
 print apc_fetch('hello');
?>