Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
CGI question
Matt Taylor
4/22/2005 8:00:00 PM
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....
auction:
http://members.ebay.com/aboutme/www-r...
1 Answer
dominic sisneros
4/28/2005 6:49:00 AM
0
|From rails wiki =>
http://wiki.rubyonrails.com/rails/show/Howt...
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
>
>
>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
CGI question
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password