CGI question

Hi,

Rather new to ruby. Making my first rails app.

The application is a simple gallery image viewer.

I'm wanting of course to have the browser cache as much as possible.

I'm looking at using etags and If-Modified-Since so I can return a 304
instead of pushing the entire image back to the browser.

putting the etag in the headers for the response is no problem

@response.headers["ETag"]=@image.etag

The thing I can't seem to figure out though is how to tell if the
browser is sending the 'If-Modified-Since' directive.

The stock CGI class seems to have no notion of such a thing and I'm
going nuts trying to figure out how to get access to the raw CGI
environment (ENV seems to be blank, perhaps a security feature?)

Thanks in advance for any help.

Matt

P.S. I tried to join the rails mailing list but so far it doesn't seem
to be working. Is that list still valid? -M

···

--

mailto:mtaylor@rexbot.com
web: http://www.rexbot.com
auction: http://members.ebay.com/aboutme/www-rexbot-com/

From rails wiki => http://wiki.rubyonrails.com/rails/show/HowtoSendFiles

def http_if_modified_since?(path)
        if since = @request.env['If-Modified-Since']
            begin
                require 'time'
                since = Time.httpdate(since) rescue Time.parse(since)
                return since < File.mtime(path)
            rescue Exception
            end
        end
        return true
    end
end>

Matt Taylor wrote:

···

Hi,

Rather new to ruby. Making my first rails app.

The application is a simple gallery image viewer.

I'm wanting of course to have the browser cache as much as possible.

I'm looking at using etags and If-Modified-Since so I can return a 304
instead of pushing the entire image back to the browser.

putting the etag in the headers for the response is no problem

@response.headers["ETag"]=@image.etag

The thing I can't seem to figure out though is how to tell if the
browser is sending the 'If-Modified-Since' directive.

The stock CGI class seems to have no notion of such a thing and I'm
going nuts trying to figure out how to get access to the raw CGI
environment (ENV seems to be blank, perhaps a security feature?)

Thanks in advance for any help.

Matt

P.S. I tried to join the rails mailing list but so far it doesn't seem
to be working. Is that list still valid? -M