I have this endpoint that will write a static file with json data in to it.
fs.writeFile("name.json", JSON.stringify(JSON.parse(data)), function (err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});
And then i have another endpoint that will send the data inside this json file.
const fileData = require("./name.json")
res.json(fileData)
However after i trigger a change inside the file and then try to get that new data its not getting the new data instead sends the old one. But if i refresh the server and then try to get it it will send me the new data. I can see inside the file that changes are there after i write data but it still doesn't send the new data. It feels like some kind of caching. Ive tried to disable etag but still no success.
app.set('etag', false)
app.use(express.static("*", {
etag: false,
}))