I have a mobile app that will periodically pull a JSON file from a Node.js server.
THE JSON response is dynamically generated with random values. It should not be cached at all.
I tried to prevent caching:
app.get('/important.json', function(req, res) {
res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
res.setHeader("Pragma", "no-cache");
res.setHeader("Expires", 0);
res.json(...);
});
However, when the mobile app reloads the json, it is still getting 304 Not Modified response from the server (Observed from Fiddler).
Can someone advise if the anti-cache is done correctly? Is it due to the etag? If etag is the problem, can I disable etag specifically for this api/endpoint?

res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); res.setHeader("Pragma", "no-cache"); res.setHeader("Expires", 0);I get 304 not modified status so you are using the cache controls correctly, it might have something to do with fiddler, try it on chrome