(Half-)technical points
linux (and other Unix-like systems, and probably any other descent OS for servers) will keep recently/often used file data in RAM. In linux this is called the "pagecache".
For directories, linux also keeps recently looked-up file names, and recently listed directories in "dentry" (directory entry). This way looking-up the same name again and again does not cause a disk access, and does not even need to go though the specific file-system layer code (say, ext3).
So linux keeps both file data and meta-data in RAM if a file is often used. This occurs in the kernel, so:
- Apache and other linux processes do not have to do anything;
- different processes share the linux file-system caching features; if some programs needs to read a file another program recently read (or wrote), it will benefit from the cache.
If every program had to implement its own disk cache, than these would each take memory, even if they needed the same files. (Also it would get messy if some process was swap-out, with its RAM file cache!)
But the fact that a file is often entirely read, a thus is entirely cached in RAM, does not mean that repeated read only accesses to this file do not cause any disk access: since linux like other Un*x has a concept of file last access time (atime
), it will have to update the file meta-data on disk regularly - unless your turn off access time updating at the fs level (option noatime
). Before doing so, you will have to make sure that nothing depends on correct access times. This is mostly an issue with personal computers, where atime
update prevents disk sleep, it probably does not matter much on servers. I mention that mostly for completeness.
The real question
Have you profiled your system? Have you identified specific performance problems?