document.lastModified returns current time for remote file

NEW
Unassigned

Status

()

Core
DOM: Core & HTML
12 years ago
8 years ago

People

(Reporter: Paul Arzul, Unassigned)

Tracking

Trunk
x86
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

12 years ago
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Firefox/1.0.7 (Ubuntu package 1.0.7)
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922 Firefox/1.0.7 (Ubuntu package 1.0.7)

document.lastModified should return the start of epoch if no
last-modified http header is sent.

according to johnny stenback in bug 116,598 comment 16[1], it looks like
we've made "document.lastModified = now when no last-modified header is
sent. This should make us compatible with IE." (april 2003)

that makes it impossible(?) to tell if a document is undated. well
established tests now fail:

<script type="text/javascript">
  if (Date.parse(document.lastModified) != 0)
    document.write('Last modified: ' + document.lastModified);
</script>

david flanagan, in _javascript the definitive guide_ 4th edition page
559:

---8<---
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.

Web servers are not required to provide last-modified dates for the
documents they serve. When a web server does not provide a last-modified
date, JavaScript assumes 0, **which translates to a date of midnight,
January 1, 1970, GMT**. The following example shows how you can test for
this case.

[emphasis mine; equivalent example removed]
--->8---

neither microsoft's[2], nor mozilla's[3] documentation mention this edge
case. i think netscape 4.x sets a clear dom0 precedent[4]. this bug
makes scripts such as peter-paul koch's last modified date[5] lie with:

"Page last changed today" (firefox 1.5 & nightly)

when in reality we've no idea when it was last modified since there's
no last-modified header.

i'd welcome a workaround that doesn't involve a ridiculous second http
request via XMLHttpRequest for what should have been accurately reported
first time round.

is compatibility with ie behaviour this important?

- p

--
tested under firefox 1.5 & 1.6a1
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a1) Gecko/20060103 Firefox/1.6a1

1.
Bug 116598 - document.lastModified doesn't show the "date" header if no "last-modified" header is sent
https://bugzilla.mozilla.org/show_bug.cgi?id=116598#c16

2.
lastModified Property (document) (Internet Explorer - DHTML)
http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/lastmodified.asp

3.
DOM:document.lastModified - MDC
http://developer.mozilla.org/en/docs/DOM:document.lastModified

4.
http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/document.html#1193811
http://web.archive.org/web/20040603154112/http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/document.html#1193811

5.
JavaScript - Last modified
http://www.quirksmode.org/js/lastmod.html


Reproducible: Always

Steps to Reproduce:

Actual Results:  
Page last changed today


Expected Results:  
Page last changed 36 years ago


If PPK's script was modified to include the standard test in the example given -- then it could have reported: "Page not dated."
Confirmed.
http://lxr.mozilla.org/seamonkey/source/content/base/src/nsDocument.cpp#4927
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: general → nobody
QA Contact: ian → general
You need to log in before you can comment on or make changes to this bug.