SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting Page Date Modified from page

    How can retrieve the modified date from a html via the url?

    http://domain.com/somepage.php

    Is there a script I can write that can go check a page and get this date.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You can't do it. The modified time is not part of the HTTP response, so it's not something you can learn by accessing a URL.

  3. #3
    SitePoint Addict
    Join Date
    Jan 2007
    Posts
    344
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Grossman View Post
    You can't do it. The modified time is not part of the HTTP response, so it's not something you can learn by accessing a URL.
    Umm, what about the http "Last-Modified" header?

    Some sites may hide it, but most don't bother. Especially as the search engines like to see it. Caching mechanisms also depend on it. So really, it's pretty much always available on any semi-compliant server.

    www.w3.org/Protocols/rfc2616/rfc2616.html

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by plumsauce View Post
    Umm, what about the http "Last-Modified" header?

    Some sites may hide it, but most don't bother. Especially as the search engines like to see it. Caching mechanisms also depend on it. So really, it's pretty much always available on any semi-compliant server.

    www.w3.org/Protocols/rfc2616/rfc2616.html
    Sorry, but that header is obsolete and not to be expected anymore. Etags and more specific cache control have replaced it.

    Apache 2.x default configuration does not send the last-modified header. I verified this by testing several live websites on different servers (including this website).

    HTTP/1.0 200 OK
    Date: Sat, 12 Sep 2009 09:18:05 GMT
    Server: Apache/2.2.3 (CentOS)
    X-Powered-By: PHP/5.2.10
    Expires:
    Cache-Control:
    Pragma:
    Etag: "629126db2c501a6cbf7bc7f3307c62fc"
    Connection: close
    Content-Type: text/html; charset=utf-8

    ...
    HTTP/1.1 200 OK
    Date: Sat, 12 Sep 2009 09:59:48 GMT
    Server: Apache/2.0.46 (Red Hat)
    Set-Cookie: mobify=0; path=/; domain=.sitepoint.com; expires=Sat, 12-Sep-2009 11:59:48 GMT
    X-Powered-By: PHP/4.3.11
    Cache-Control: private, max-age=600
    Set-Cookie: SID=b66a9da10d3b87fe4aac89e58e0ae34c; path=/
    Set-Cookie: SPabc=c; expires=Sun, 12 Sep 2010 09:59:51 GMT; path=/
    Transfer-Encoding: chunked
    Content-Type: text/html

    ...

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •