node.js page in different tabs shows the same page source code

I'm new in node.js, my code is:

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.write('<p>' + Math.random() + '</p>');
  res.end();
}).listen(1337);

access the url in firefox with two browser tabs, tab1 shows 0.6157466806471348, tab2 shows 0.029988145222887397, no problem. But, when viewing the page source, both tabs show the same (newer) value. Is that normal? How should I do to avoid that?

Yes, it's because your browser caches page sources and when you are trying to view it, shows the latest loaded page.

If you add some logging, you'll understand what i mean.

    http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/html'});
      res.write('<p>' + Math.random() + '</p>');
      res.end();
      console.log('Message has been sent');
    }).listen(3000);

When you open your page in new tab, you can see in console that browser loads new version of it. But when you trying to view the source browser doesn't load anything.

If you want to avoid this behaviour, try to reload the source, after you open it.