node.jsdatehttp-headersif-modified-since

Parse If-Modified-Since Header (node.js)


I am trying to implement sending a 304 header for performance in a server hosting program I am writing, but I do not know how to parse the date of the If-Modified-Since header. I also would like to know how to find out if the If-Modified-Since date is older/newer than another date that I have in my code.


Solution

  • To parse the date, use new Date(datestring) or Date.parse(datestring). To see if a date is newer or older than another date, use the greater than (>) and less than (<) operators.