Forum: Ruby on Rails Caching and mongrel

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Mario J. (Guest)
on 2007-05-22 18:36
(Received via mailing list)

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:


Does anyone know what is going on there?  Is this a mongrel cache
Mario J. (Guest)
on 2007-05-23 21: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.