Are disk reads cached on DH shared hosting? on VPS?

Hi everyone, I’m wondering about caching of file reads. My site is on shared hosting. I may put it on a VPS to get the advantage of xcache, but that is for PHP opcodes.

Suppose you have in a script:

include( ‘filename.ext’ );

Does this require disk I/O on every request? Or does Linux cache the file read?

This page:
indicates that the OS caches the data from the read so that the next time the PHP interpreter tries to retrieve the file, it may look like disk I/O from the PHP point of view, but the data comes from a memory cache.

But that’s assuming a more or less standard physical machine, maybe dedicated to the web server role. I’m wondering whether this also happens on Dreamhost shared hosting, and whether it is true on a VPS.

I looked in this forum and in the wiki and found nothing really on point (the nearest I found was , but it is only incidentally relevant).

Disk caching is always enabled.

On shared hosting, though, keep in mind that the cache is shared across all customers, so the lifetime of data in the cache may be shorter than you might expect.

Thank you for the info! That does make sense.

And on a VPS, it would be longer?

On VPS, disk cache for your VPS is taken from its own memory allocation, so data in your disk cache will typically stay there unless memory pressure within your VPS causes it to be evicted.

Good to know.

Another thread here suggests that there is some memory pressure on VPS due to total cache. However, logically it seems that as long as the persistence time of the disk read data is more than the time to handle a few requests, it is beneficial, and a design that relies on loading some files is viable.