[html5] document.lastModified clarification

Jukka K. Korpela jukka.k.korpela at kolumbus.fi
Wed Sep 3 03:41:47 PDT 2014


2014-08-29 6:55, Ken Koski kirjoitti:
> According to 
> http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#dom-document-lastmodified, 
> if the date and time are not known, "the attribute must return the 
> current date and time". Does current in this case mean the timestamp 
> for when the document was retrieved, or does it mean that 
> document.lastModified is equivalent to "new Date()" whenever the 
> attribute is accessed?

The natural interpretation is the latter, since "current" refers to the 
moment at hand.

> It appears that Firefox uses the first meaning and Chrome uses the 
> latter meaning.
>

How did you test this? With a server that does not send a Last-Modified 
header? Or with a local file? Testing with a local file, I observed that 
Firefox and IE return the last modification time of the file on disk, 
whereas Chrome returns the current time (of referring to 
document.lastModified). I think the latter is wrong:

"The|Document 
<http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#document>|'s 
source file's last modification date and time must be derived from 
relevant features of the networking protocols used, e.g. from the value 
of the HTTP|Last-Modified 
<http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#http-last-modified>|header 
of the document, or from metadata in the file system for local files."

Thus, a note a little earlier, saying "Returns the date of the last 
modification to the document, as reported by the server" is misleading. 
I think it should minimally have "e.g." after the comma.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/



More information about the Help mailing list