# Caching & Attachments

**URL:** <https://www.ruby-forum.com/t/caching-attachments/96681>\
**Category:** Rails\
**Created:** [June 30, 2006, 7:57pm UTC](https://www.ruby-forum.com/t/caching-attachments/96681 "2006-06-30T19:57:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeff\_LaMarche](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c5a1d2/32.png) [@Jeff\_LaMarche](https://www.ruby-forum.com/u/Jeff_LaMarche)\
**Post date:** [June 30, 2006, 7:57pm UTC](https://www.ruby-forum.com/t/caching-attachments/96681/1 "2006-06-30T19:57:55Z")

</div>

I’m noticing a different behavior between development and production  
environments when I use caches\_action along with send\_data.

I have a method:

def image  
@thePic = Picture.find(params[:id])  
send\_data(@thePic.image.data, :filename =\> @thePic.image.filename,  
:type =\> @thePic.image.content\_type, :disposition =\> “attachment”)  
end

Which works fine; it returns an image as expected, which is downloaded  
by the browser. When I add a declaration:

caches\_acton :image

it continues to work fine in development, presumbably because it doesn’t  
cache in development mode. When I switch to production mode, however,  
this no longer causes the file to be downloaded to the desktop, but  
rather it opens up in the browser as if it were a text file.

I am not using url mapping, so the “image” url is something like  
localhost:3000/gallery/image/3 which may be part of the problem - the  
browser may not “recognize” it as an image, even though I am passing in  
content-type and filename and telling it it’s an attachment.

Can anyone offer any help or suggestions.
