Shea Martin wrote the following on 02.08.2007 17:24 :
> I would like to open a webpage, only if the page is newer than what I 
> already have.
>
> It looks like I have to get the whole page to get the last_modified 
> value.  I can't see anyway else to get the value, say off of the 
> Net::HTTP::HEAD.
>
> I was hoping to save some bandwidth, am I SOL?
>
> ~S
>

You don't use the last_modified value like that. You make a simple GET 
but you pass headers to tell the server that you only want the whole 
page if the content has been modified.

So you'll have to
1/ store the 'last-modified' and 'etag' headers in the response (when it 
has been modified, on first fetch or when the server is updated to put 
them in the response).
2/ put them in the headers of your get request when you have them, like 
that:

headers = {}
headers["If-Modified-Since"] = last_modified if last_modified
headers["If-None-Match"] = etag if etag

3/ check that response.is_a?(Net::HTTPNotModified)

Lionel