I'm interested in adding a far-forward expiry header to the Response  
when Merb (or rather Rack) serves static assets, specifically images.  
 From what I've read it seems that Merb is using Merb::Rack::Static to  
serve static files:

(from my config.ru)

        use Merb::Rack::Static, Merb.dir_for(:public)

This in turn is using ::Rack::File to serve the images:

     def serving
       if size = F.size?(@path)
         body = self
       else
         body = [F.read(@path)]
         size = Utils.bytesize(body.first)
       end

       [200, {
         "Last-Modified"  => F.mtime(@path).httpdate,
         "Content-Type"   => Mime.mime_type(F.extname(@path), 'text/ 
plain'),
         "Content-Length" => size.to_s
       }, body]
     end

Ordinarily, the mtime of a file seems reasonable as a Last-Modified  
date, but as I'm using Heroku, I do a git push to that server and the  
mtime gets set to the current push time, not when the image last  
changed. Also, I'd like to add a Cache-Control header to the response  
as well and take advantage of the upstream HTTP accelerator that  
Heroku use, i.e. Varnish.

So, short of monkeypatching the Rack::File module, does anyone know of  
a way to hook into the serving process and add a header? Or is this  
something I need to ask the Rack list?

Thanks,

Andy Shipman





--

You received this message because you are subscribed to the Google Groups 
"merb" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/merb?hl=en.


Reply via email to