From: Lionel Bouton Date: 2007-08-03T04:45:35+09:00 Subject: Re: net::http and caching files Shea Martin wrote the following on 02.08.2007 20:35 : > I have just tried about 20 servers (random urls), and have not seen > and etag or last_modified on any of them. Is there really that few of > servers which support the two? > > Am I doing something wrong? > > I am on win32 if it matters. > > CODE: > require 'open-uri' > > # h = {} > # h['If-Modified-Since'] = 'Thu, 09 Aug 2007 17:33:40 GMT' > http = Net::HTTP.new( "www.google.com" ) > resp, data = http.get( "/index.html" ) > p "r is #{resp}" > p "code is #{resp.code}" > resp.each { |k,v| p "#{k} = #{v}" } > > #open( "http://google.ca" ) do |f| > # p f.last_modified > #end > > exit 0 Of course google won't send you last_modified or etag headers they don't have documents to tag with an etag or to mark as generated at a given time. If they want to optimize the bandwidth they are far more likeliy to use cache-control headers, which they do for their main page with: "Cache-Control: private" Look at RSS or Atom feeds, between 1/3 to 1/2 of them have "last-modified" headers, they are "modified" when a new article or comment is posted... Lionel.