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.
| SitePoint Sponsor |
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.


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.
17-29% of paid ad clicks are fraudulent. Get protected with Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more.


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
...
17-29% of paid ad clicks are fraudulent. Get protected with Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more.
Thanks for the help.
Bookmarks