MacOS – Finder shows stale directory listings from NFS server

findermacosnfs

I have an Ubuntu 12.04 Linux server sharing files via NFSv4. I mount the share on my MacBook Pro running Mac OS X 10.7.5. I have the NFS share set up to automount in Disk Utility with default mount options.

I find that when changes happen on the server in a directory that I have had open in the Finder recently, the Finder does not reflect the changes for a very long time. If I use the terminal to "ls" the same directory, I see the changes. It seems that the Finder is caching directory listings locally, and that this caching is very aggressive.

Closing and reopening the window doesn't help. Force quitting the Finder does not help. Unmounting and remounting the NFS share does not help. Rebooting works, but that's a very blunt instrument.

Has anyone experienced this, and does anyone know of any workarounds? I'm looking to eliminate the caching, so that the Finder does to the VFS layer on every access, or at least shorten the TTL of the cached data.

I've evaluated changing the share to SMB or AFP, but I cannot undertake that and am looking for a way to manually invalidate Finder's cache (or otherwise poke at it) if I can't change Finder's behavior outright.

ETA: This doesn't seem to be an issue any more in Mavericks.

Best Answer

I had the same problem and found a solution here that worked for me:

dscacheutil -flushcache
killall Finder

The man page of dscacheutil says that the -flushcache option should only be used in extreme cases, so there may be risks to this method that I'm not aware of.