Instantly reclaimable disk caches should count as available, and they do.
This isn’t hard. The OS should just expose a counter for available memory instead of having applications understand every type of memory reservation.
edit:
Linux does this, but it has its own share of issues with memory counters. The “cached” memory includes tmpfs and ramfs for seemingly no reason.
That metric would give you a number of bytes which can be used for pages not backed by files, but it won't give you actual memory usage statistics:
It won't count executable pages and memory-mapped file use as "used" memory, so your system might display gigabytes "free" when it's starving, executables getting paused when code pages are paged-in from disk.
It's just less useful than what's displayed now. "Everyone is doing it wrong" is usually a signal that you're missing something.
Linux MemAvailable from /proc/meminfo is just an estimation calculated as an arbitrary percentage (50%) of free and potentially reclaimable memory.
You can't determine how much of the memory can actually be reclaimed under memory pressure until you try to reclaim it.
> The “cached” memory includes tmpfs and ramfs for seemingly no reason.
If you're curious why that is by the way, it's because that's actually how these are implemented (tmpfs/ramfs is just a mount to a filesystem where the files never get marked clean[1])
[1]: https://www.kernel.org/doc/Documentation/filesystems/ramfs-r...