Getting modification time of remote files (on a website).

S

Susan Harris

I need to read a bunch of xml files that are held in a publically readable
website directory. However, some of them are on the large side and I only
want to read them if they've changed. Is there anyway I can retrieve the
last modified date from these remote files?

It's a third party server, so I can't do anything at the server side.
 
A

Alberto Poblacion

Susan Harris said:
I need to read a bunch of xml files that are held in a publically readable
website directory. However, some of them are on the large side and I only
want to read them if they've changed. Is there anyway I can retrieve the
last modified date from these remote files?

It's a third party server, so I can't do anything at the server side.

There is no universal method to retrieve from a web server the last
modified date of the files, but there is an alternative: In your HTTP
request you can add the header "If-Modified-Since" accompanied by the date
when you last retrieved the file. If it has not chaged since that date, you
will get back a status code 304; otherwise you will get back the new version
of the file.

See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html (section
14.25).
 
H

Hans Kesting

After serious thinking Susan Harris wrote :
I need to read a bunch of xml files that are held in a publically readable
website directory. However, some of them are on the large side and I only
want to read them if they've changed. Is there anyway I can retrieve the last
modified date from these remote files?

It's a third party server, so I can't do anything at the server side.

How are you getting those files? Through http?
There is an If-modified-since header to specify that you only want to
get the file if it was changed since the specified date. If not
changed, you will get a 304 (not modified) response.

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top