79

Is there a way to find out how much time has passed since a web page was changed?

For example, I have a page hosted at: www.mywebsitenotupdated.com

Is there a way to find out when this HTML page was uploaded to the server?

I have no access to server; just a link to the webpage.

6 Answers 6

76

No, you cannot know when a page was last updated or last changed or uploaded to a server (which might, depending on interpretation, be three different things) just by accessing the page.

A server may, and should (according to the HTTP 1.1 protocol), send a Last-Modified header, which you can find out in several ways, e.g. using Rex Swain’s HTTP Viewer. However, according to the protocol, this is just

“the date and time at which the origin server believes the variant was last modified”.

And the protocol realistically adds:

“The exact meaning of this header field depends on the implementation of the origin server and the nature of the original resource. For files, it may be just the file system last-modified time. For entities with dynamically included parts, it may be the most recent of the set of last-modify times for its component parts. For database gateways, it may be the last-update time stamp of the record. For virtual objects, it may be the last time the internal state changed.”

In practice, web pages are very often dynamically created from a Content Management System or otherwise, and in such cases, the Last-Modified header typically shows a data stamp of creating the response, which is normally very close to the time of the request. This means that the header is practically useless in such cases.

Even in the case of a “static” page (the server simply picks up a file matching the request and sends it), the Last-Modified date stamp normally indicates just the last write access to the file on the server. This might relate to a time when the file was restored from a backup copy, or a time when the file was edited on the server without making any change to the content, or a time when it was uploaded onto the server, possibly replacing an older identical copy. In these cases, assuming that the time stamp is technically correct, it indicates a time after which the page has not been changed (but not necessarily the time of last change).

1
  • It's correct about the Last-Modified header, however it's possible to make some educated guesses from the server's response to a HEAD request and based on knowledge of a particular host's server and their content and how they generate it; Snooping around in their pages and with a sniffer on the connection can reveal much. Feb 5, 2020 at 20:32
65

Open your browsers console(?) and enter the following:

javascript:alert(document.lastModified)
5
  • 14
    You can just print it out in the console too. Just type document.lastModified
    – daamsie
    May 14, 2014 at 2:20
  • 7
    The answer below should really be the accepted answer, since dynamic pages are generated on the fly, and this command is worthless in that context. It is a useful command though for static pages (if you can determine a page is truly static).
    – Joyrex
    Jun 17, 2015 at 15:17
  • 14
    Hello. when I searched for this, in the console: I get my system's current date and time: javascript:alert(document.lastModified) Not the actual date
    – raja777m
    Mar 29, 2016 at 18:45
  • 3
    @raja777m perhaps you are trying this for a dynamic webpage Dec 20, 2016 at 7:31
  • This would show incorrect data if a website had moved server wouldn't it?
    – Eoin
    Sep 9, 2020 at 11:28
18

There is another way to find the page update which could be useful for some occasions (if works:).

If the page has been indexed by Google, or by Wayback Machine you can try to find out what date(s) was(were) saved by them (these methods do not work for any page, and have some limitations, which are extensively investigated in this webmasters.stackexchange question's answers. But in many cases they can help you to find out the page update date(s):

  1. Google way: Go by link https://www.google.com.ua/search?q=site%3Awww.example.com&biw=1855&bih=916&source=lnt&tbs=cdr%3A1%2Ccd_min%3A1%2F1%2F2000%2Ccd_max%3A&tbm=
    • You can change text in search field by any page URL you want.
    • For example, the current stackoverflow question page search gives us as a result May 14, 2014 - which is the question creation date: enter image description here
  2. Wayback machine way: Go by link https://web.archive.org/web/*/www.example.com
    • for this stackoverflow page wayback machine gives us more results: Saved 6 times between June 7, 2014 and November 23, 2016., and you can view all saved copies for each date
2
  • 1
    Wayback machine is an amazing tool! It tells you, for a given page, when it was updated, but you can also visit the different snapshots it does of this page. You can accuretly check if the section you are interested in is pretty old, or pretty new. Wayback machine is the real answer to this question. Mar 6, 2018 at 10:20
  • 2
    the API for wayback machine lets you see a list of all versions of a page in the order they were archived. You could then scan several of them to determine when that page no longer existed. But you'd have to pull each version and to a diff check to see when it was last modified. Jul 3, 2018 at 15:12
4

For checking the Last Modified header, you can use httpie (docs).

Installation

pip install httpie --user

Usage

$ http -h https://martin-thoma.com/author/martin-thoma/ | grep 'Last-Modified\|Date'
Date: Fri, 06 Jan 2017 10:06:43 GMT
Last-Modified: Fri, 06 Jan 2017 07:42:34 GMT

The Date is important as this reports the server time, not your local time. Also, not every server sends Last-Modified (e.g. superuser seems not to do it).

1

This is a Pythonic way to do it:

import httplib
import yaml
c = httplib.HTTPConnection(address)
c.request('GET', url_path)
r = c.getresponse()
# get the date into a datetime object
lmd = r.getheader('last-modified')
if lmd != None:
   cur_data = { url: datetime.strptime(lmd, '%a, %d %b %Y %H:%M:%S %Z') }
else:
   print "Hmmm, no last-modified data was returned from the URL."
   print "Returned header:"
   print yaml.dump(dict(r.getheaders()), default_flow_style=False)

The rest of the script includes an example of archiving a page and checking for changes against the new version, and alerting someone by email.

0

For me it was the

article:modified_time

in the page source.

View Page Source

Not the answer you're looking for? Browse other questions tagged or ask your own question.