Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Last Modified Date of a file on a web site

Tags:

html

http

Is there a way to get the Last-Modified-Date of a file on a Web Site?

i.e. Here is an example file I have out there: http://www.ymcadetroit.org/atf/cf/%7B2101903E-A11A-4532-A64D-9D823368A605%7D/Birmingham_Youth_Sports_Parent_Manual.pdf

like image 998
Gerhard Weiss Avatar asked Jun 23 '09 19:06

Gerhard Weiss


2 Answers

You can do the following to get Last-Modified: https://superuser.com/a/991895

Using curl:

curl -s -v -X HEAD http://foo.com/bar/baz.pdf 2>&1 | grep '^< Last-Modified:'

Using wget:

wget --server-response --spider http://example.com/bar/example.pdf 2>&1 | grep -i Last-Modified
like image 164
Adrian Silveanu Avatar answered Nov 16 '22 00:11

Adrian Silveanu


The HTTP intends the Last-Modified header field to declare the last modification date. But the server needs to know that date.

On static files whose content is sent directly to the client and not interpreted otherwise by the server (e.g. .html, .css, .js) it uses the last modified date of that file. But on files that generated content dynamically (PHP, Python, etc.) the script needs to specify that information itself. But unfortunatly many scripts don’t to that.

So if a Last-Modified header field is present, you can use that information. But if not, you cannot determin the last modification date.

like image 37
Gumbo Avatar answered Nov 16 '22 02:11

Gumbo