Add Date header to HTTP responses #2751

Closed
wants to merge 18 commits into
from

Projects

None yet

3 participants

@mnot

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

@isaacs

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.

Cheers,

@isaacs

Nice :)

@tj

function utcDate(

@mnot

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

@isaacs

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.

@mnot

No worries; see pull 2753.

@mnot

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