Linux keeps recently used files in memory, which is why the second read is often much faster. free gives the total. This tool, part of util-linux, tells me about one specific file.
fincore /var/lib/example/data.db
The output has the columns RES (bytes of the file that are in memory), PAGES, SIZE and FILE. When RES is close to SIZE, the whole file is cached. You can give it several files at once, and choose columns:
fincore --bytes -o RES,SIZE,FILE *.db
Use it to understand odd timings. If a benchmark is suddenly fast on the second run, check whether the test file was simply sitting in memory. Or see which of your database or media files the system has actually kept around.
I read the answer as a snapshot. The kernel can drop those pages a moment later when something else needs the RAM, and that is normal behaviour, nothing to fix. On Ubuntu releases where the command is missing, look for it in the util-linux-extra package. It reports on regular files you can open, so you may need sudo.
Further reading: fincore(1) man page
Going deeper: Keep a domain pointed at your home with Cloudflare DDNS on Unraid