Add Date header to HTTP responses #2751

wants to merge 18 commits into


None yet

3 participants


... if not already present. Includes a res.sendDate control (default true) and documentation, tests.


It seems like this is going to do extra date lookups when idle. How about this approach instead?

var dateCache = null
function utcDate () {
  if (dateCache) return dateCache;
  dateCache = new Date().toUTCString();
  setTimeout(function () {
    dateCache = null
  }, 1000)
  return dateCache;

Of course, it's not like 1 syscall every second is really all that expensive ;)

Yep, I thought the same thing when I was out for lunch :) Also, it's not as accurate as it could be. See most recent commit fead685.



Nice :)


function utcDate(


Sorry about the nasty history; I was working on two machines.


Can you please squash into a few atomic commits (or just one) and rebase onto joyent/master? (If it's too much of a pita, I can do it.)

Also, minor nit, please use camelCase rather than snake_case.


No worries; see pull 2753.


Think this can be closed...

@mnot mnot closed this Feb 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment