Answer the question
In order to leave comments, you need to log in
How to return 304 status in express?
I wrote a condition to return a 304 status and added a test header to see if my condition actually works.
app.get('/', (req, res, next) => {
const modifiedSince = req.get('If-Modified-Since')
if (modifiedSince) {
res.append('Test-Header', '*');
res.status(304).end();
} else {
res.sendFile(path.join(__dirname + '/index.html'));
}
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question