How does NFS read cache work on Debian?

First, NFS does not provide cache coherency, so if you need that, you must look elsewhere.

What NFS specifies is a weaker model called close-to-open consistency. Meaning that when a file is closed, any dirty data are flushed to the server. Conversely, when a file is opened, an attribute check is performed, meaning that if the client has cached pages from that file, it checks whether those pages are still valid.

While not in the spec itself, most NFS clients have something called attribute cache timeout, i.e. how old the attributes of a directory or opened file can be before the client contacts the server to revalidate them. On Linux, see the actimeo= etc. mount options. Higher values allow more aggressive caching, but increase the risk of using stale data if some other client updated the file in the meantime.

Leave a Comment