Open vamsaya opened 1 month ago
There isn't anything available out of the box but you can quickly create this functionality yourself.
import fs from "node:fs/promises";
const filename = "./index.html";
let file = Bun.file(filename);
const itterator = fs.watch(filename);
for await (const event of itterator) {
// Care you should deduplicate updates. We might get 2 change events.
file = Bun.file(filename);
}
What is the problem this feature would solve?
In Bun.serve, when a request is index.html, it has to be read from disk every time, and the response speed is not very fast. If you load index.html content into memory, the response speed is at least 3 times faster.
What is the feature you are proposing to solve the problem?
However, if the index.html content changes, the content that has been loaded into memory does not change with it. So is it possible to automatically update disk content changes to memory in Bun.file?
What alternatives have you considered?
No response