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.
The lastModified property returns the date and time the document was last modified.
javascript:alert(document.lastModified)A JavaScript alert window will pop open displaying the last date and time the page was modified. For users of the Chrome browser and some others, if you cut-and-paste the command into the address bar, be aware that the "javascript:" part is removed.
lastModified is a read-only string property that contains the date and time at which document was most recently modified. This data is derived from HTTP header data sent by the web server. The web server generally obtains the last-modified date by examining the modification date of the file itself.
Javascript has provided a command called document. lastModified to get the instance when the document is last modified. This command will provide the exact date and time of modification.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With