Let's say we have a simple index.php
file that goes:
<?php
inclde('file1.php');
inclde('file2.php');
inclde('file3.php');
Presumably, this will ultimately result in three additional separate I/O requests to the disk, on top of index.php
when the file is served.
Now, let's say this file is placed on a website and frequently requested. It would make sense if these files are somehow cached in memory, rather than make I/O requests every time someone visits the website.
Questions:
- Does Apache httpd cache
index.php
? - What about the 3
include()
operations? - Does PHP request the files from OS through Apache? Does it matter which mpm model is used?
- Does nginx, lighttpd or any other webservers do caching?
- Does this also depend on the OS filesystem? i.e. will Linux OSes generally cache files that are frequently accessed?
- Or is there caching at an even lower-level?
- Or does PHP or any other server application engine somehow cache the files and I/O requests never make it to the OS?
Since disk I/O is usually the biggest bottleneck, knowing how files are cached at various levels by a web server can help in tweaking of performance, and even application development, e.g. perhaps concatenating short application files rather than multiple includes help performance.
Thanks for helping!