Does readFileSync of node.js cache the read files?

caching, file, node.js

Solution

Reads are buffered during a given read operation. E.g. when you ask to read a byte, it will likely read many more bytes than a single byte into a buffer and then return that single byte to you. But beyond that, there is no caching built into node.js from one read of the file to another. And, if you're using `readFileSync()` to read the whole file at once, this buffering wouldn't affect you.

The OS itself will do caching underneath node.js, but that is usually write-through caching which is designed to save disk reads, but never have stale data.

Problem

Does `fs.readFileSync` of node.js cache files that's been read? I don't think it does because doc doesn't say so, but my code is behaving that way.. - edit Relevant part of code ``` // after mainPath file is altered, it's not reflected until I restart node.js var scriptString = fs.readFileSync(mainPath); var app = vm.createScript(scriptString, mainPath); // Run the app app.runInContext(context); ```

Original source