Javascript document.lastModified is returning current date and time

html, javascript

Solution

document.lastModified I imagine is based on the HTTP Response Header field Last-Modified (RFC2822). Last-Modified is usually used in conjunction with the Request header field If-Modified-Since for caching purposes.

Like other header fields, it's server implementation specific as to what value is returned. The server software replying to your HTTP Request might or might not return the Last-Modified header field in the HTTP Response.

In the pages you are running this on, the server simply returns the current date. Same is true for this page.

However execute document.lastModified (in Dev Tools) on say https://developer.mozilla.org/en-US/docs/Web/API/document.lastModified, you'll get 11/13/2013 09:13:29

Using firebug in Firefox or Chrome Dev Tools in Chrome, you can see inspect HTTP traffic data in the Network tab.

Problem

I'm using the standard `document.lastModified` Javascript property to output the supposed last modified date of the page, but it's outputting the actual current date and time. Any clue as to why it'd behave this way as opposed to outputting the actual last modified property of the page? This happens both locally (on my machine) as well as the published page on the delivery server.

Original source