Javascript document.lastModified返回当前日期和时间 [英] Javascript document.lastModified is returning current date and time

查看:486
本文介绍了Javascript document.lastModified返回当前日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用标准的 document.lastModified Javascript属性来输出页面的假定的最后修改日期,但它输出的是实际的当前日期和时间。任何线索,为什么它的行为方式与输出页面的实际最后修改属性相反?这在本地(在我的机器上)以及在传送服务器上发布的页面上都会发生。

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.

推荐答案

文档。 lastModified 我想是基于HTTP响应标题字段 Last-Modified RFC2822 )。 Last-Modified通常与Request头字段If-Modified-Since一起用于缓存目的。

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.

与其他头字段一样,它的服务器实现特定于什么值退回。回复HTTP请求的服务器软件可能会也可能不会返回HTTP响应中的Last-Modified标头字段。

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.

然而,执行 document.lastModified (在Dev Tools中),例如 https://developer.mozilla.org/en-US/docs/Web/API/document.lastModified ,你会得到 11/13/2013 09:13:29

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

在Firefox中使用firebug或在Chrome中使用Chrome Dev Tools ,您可以在网络中查看HTTP流量数据标签。

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

这篇关于Javascript document.lastModified返回当前日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆