# Caching and mongrel

**URL:** <https://www.ruby-forum.com/t/caching-and-mongrel/104791>\
**Category:** Rails\
**Created:** [May 22, 2007, 4:36pm UTC](https://www.ruby-forum.com/t/caching-and-mongrel/104791 "2007-05-22T16:36:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrnice](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/82dd89/32.png) [@mrnice](https://www.ruby-forum.com/u/mrnice)\
**Post date:** [May 22, 2007, 4:36pm UTC](https://www.ruby-forum.com/t/caching-and-mongrel/104791/1 "2007-05-22T16:36:37Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![mrnice](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/82dd89/32.png) [@mrnice](https://www.ruby-forum.com/u/mrnice)\
**Post date:** [May 23, 2007, 7:51pm UTC](https://www.ruby-forum.com/t/caching-and-mongrel/104791/2 "2007-05-23T19:51:49Z")

</div>

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.
