finding time when url was modified

A

Ajay

hi!

i am reading a file on the Web. How can i find out when it was last
modified?

thanks
 
S

Steve Holden

Ajay said:
hi!

i am reading a file on the Web. How can i find out when it was last
modified?

thanks
That would be the "Last-Modified" HTTP header, when it's present.

Python 2.3.4 (#1, Jun 13 2004, 11:21:03)
[GCC 3.3.1 (cygming special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.Server: Microsoft-IIS/5.0
Date: Tue, 28 Sep 2004 01:50:38 GMT
Content-Type: text/html
Accept-Ranges: bytes
Last-Modified: Wed, 25 Aug 2004 17:47:51 GMT
ETag: "242599a4cb8ac41:f460"
Content-Length: 12456

Oops, time I reinstalled the auto-update code to keep my Python links fresh!

regards
Steve
 
A

Ajay

Quoting Steve Holden said:
Ajay said:
hi!

i am reading a file on the Web. How can i find out when it was last
modified?

thanks
That would be the "Last-Modified" HTTP header, when it's present.

Python 2.3.4 (#1, Jun 13 2004, 11:21:03)
[GCC 3.3.1 (cygming special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.Server: Microsoft-IIS/5.0
Date: Tue, 28 Sep 2004 01:50:38 GMT
Content-Type: text/html
Accept-Ranges: bytes
Last-Modified: Wed, 25 Aug 2004 17:47:51 GMT
ETag: "242599a4cb8ac41:f460"
Content-Length: 12456

Oops, time I reinstalled the auto-update code to keep my Python links
fresh!

is it possible for someone to change the Last-Modified header? Can someone
put a new updated document, but in such a way that if someone requests
that document, they get an old date rather than the new date?
i can see a CGI script add its own header and then write out the document.
but can this be done with a simple HTML page?

thanks
 
P

Peter Hansen

Ajay said:
is it possible for someone to change the Last-Modified header? Can someone
put a new updated document, but in such a way that if someone requests
that document, they get an old date rather than the new date?
i can see a CGI script add its own header and then write out the document.
but can this be done with a simple HTML page?

Certainly... the server can do anything it wants with that
header, including failing to provide it, providing an invalid
date, providing a date in the future or distant past, or
even providing a date that happens to correspond exactly
with the true "last modified" date of the document...

Whether a *particular* server will do that with a *particular*
kind of document is a different question altogether.

Do you have a specific situation involving this that you
can describe, or are you just asking in general, out of
curiosity?

-Peter
 
A

Ajay

Quoting Peter Hansen said:
Certainly... the server can do anything it wants with that
header, including failing to provide it, providing an invalid
date, providing a date in the future or distant past, or
even providing a date that happens to correspond exactly
with the true "last modified" date of the document...

Whether a *particular* server will do that with a *particular*
kind of document is a different question altogether.

Do you have a specific situation involving this that you
can describe, or are you just asking in general, out of
curiosity?

thanks
it was mostly out of curiousity. I have an interchange where the servers
would send a policy and request a resource. the other server would
evaluate the policy and respond accordingly.
i am hoping to cut down on the evaluation by maintaining a record of past
transactions and if everything is the same (policy, resource ets) then
take the same action as before. one way was to store policy used earlier
and compare that with the new one and so on. since the app is for a mobile
device with low processing power, i was hoping to perhaps use modified date
- which when i thought a little more about it is clearly not feasible.

i guess comparing two really large strings is what i'll have to go with.
any ideas on performance of string comparisons?

cheers
 
S

Steve Holden

Ajay said:
thanks
it was mostly out of curiousity. I have an interchange where the servers
would send a policy and request a resource. the other server would
evaluate the policy and respond accordingly.
i am hoping to cut down on the evaluation by maintaining a record of past
transactions and if everything is the same (policy, resource ets) then
take the same action as before. one way was to store policy used earlier
and compare that with the new one and so on. since the app is for a mobile
device with low processing power, i was hoping to perhaps use modified date
- which when i thought a little more about it is clearly not feasible.

i guess comparing two really large strings is what i'll have to go with.
any ideas on performance of string comparisons?
Compare the MD5 checksums instead. Python has an MD5 function, somewhere ...

regards
Steve
 
J

Jeremy Bowers

thanks
it was mostly out of curiousity. I have an interchange where the servers
would send a policy and request a resource. the other server would
evaluate the policy and respond accordingly.

I would recommend going a little more deeply into the HTTP standards, and
then examining what the capabilities of your servers are. I have no
experience with mobile devices.

In particular, take a look at the E-Tags field; if you have support for
it, that will pretty much do exactly what you want with nearly no work on
your part if I am reading your requirements correctly; all you have to do
is catch the HTTP result code and do the right thing with it.

A shocking number of people re-implement large chunks of HTTP in the HTML,
which is painful and often ineffective. HTTP is pretty cool, if you use it
to the full and not just as a glorified file, ignoring the headers.
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top