Forum: Ruby on Rails Caching and mongrel

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
05eb1fd50435a1a6092491d528ffc740?d=identicon&s=25 Mario Jauvin (Guest)
on 2007-05-22 16:36
(Received via mailing list)
Hi,

I have turned on caching and am using the action controller directive
caches_page for an action that returns an image file (used in the HTML
img src attribute).  The first time I visit the page which contains
those img tags, all looks great and a bunch of pages are created in
the location where the cache is being stored (defaults to RAILS_ROOT +
"/public").  However, on the second visit, the page is missing some
images and when looking at the files in the cache directory, I notice
that the images which displayed correctly on the second visit contain
simply a binary image file. However, the files that did not work
contain some text like:

#<Proc:0x03dff400@C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/
action_controller/streaming.rb:68>

Does anyone know what is going on there?  Is this a mongrel cache
problem?
05eb1fd50435a1a6092491d528ffc740?d=identicon&s=25 Mario Jauvin (Guest)
on 2007-05-23 19:51
(Received via mailing list)
I found out what was going on and thought you should know.  The action
which was being  cached used the send_file action controller method.
However, (this was a pain to diagnose) when using default options
the :stream => true option will cause the data to be generated AFTER
the cache copy is taken hence the stuff in the cache is actually the
instruction to stream the file.  So, the fix is to say :stream =>
false in the send_file method and VOILA!  I guess that's why I was the
only poor soul seeing this cause probably no one caches requests
generated by send_file.
This topic is locked and can not be replied to.