Memory Profiling For Mere Mortals

Server

var http           = require(http)
  , fs             = require(fs)
  , path           = require(path)
  , templateEngine = require(any-template-engine)

var header = fs.readFileSync(path.join(__dirname, my-header.html), utf8)

// [ ...]

function onrequest(req, res) {
  var context = getContext(req);

  fs.readFile(path.join(__dirname, index.html), utf8, function onreadIndex(err, src) {
    if (err) return console.error(err)
    var html = header + templateEngine(src, context)
    serve(html)
  })
}