1

Briefly, I have created a server using nodeJS. I have installed 'morgan' for the logger. When I render my front-end everything works, my website can be accessed, RU (registered users) can book, ... However the main problem is that I am getting 304 statusCodes in my terminal.

is the problem even fixed in the backend or is the problem related to the browser (using chrome btw)? How can I solve this problem to get 200 statusCode?

if everything is working, then I should have received 200 statusCode. I have looked a lot and still haven't found a solution that works. There is a question around this in stack over flow which dates back years ago (NodeJS/express: Cache and 304 status code). The answer(s) given which is app.disable('etag'); (or the updated version: app.set('etag', false);) or using app.router which is now deprecated does not work for me.

Also when I clear cache from my browser and run my server again, I get 200 statusCode for the first time but then the second time (onwards) when nothing is changed and I refresh, I get 304 for the statusCode.

Thanks in advance.

  • I just tested ```app.disable('etag')``` and it works, so did you really tried it?. – bogdanoff Apr 13 '23 at 15:41
  • I don't understand why 304 is problem for you, etag helps browsers to cache responses by sending response hash in header. [learn more](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) – bogdanoff Apr 13 '23 at 15:44
  • @bogdanoff regarding your first comment, yes I wrote it in my app.js which is my server script. I also placed it at different lines to see whether the position of this middleware will make a difference, but still didn't work. For the second comment, I was with the impression that we should aim to get 2xx status codes (?) So, I wanted to do so and after reading several pages did not find a practical solution for this goal (or the solutions found did not work for me). – RunTimeError31415 Apr 14 '23 at 05:27

0 Answers0