Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
434 views
in Technique[技术] by (71.8m points)

html - Javascript document.lastModified is returning current date and time

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...