title: Rails Custom Header for Images
body: <p>Is it possible to modify the HEADER in Rails 3 when someone requests an image? For example:</p>
  
  <pre><code>http://localhost:3000/assets/myimg.png
  </code></pre>
  
  <p>I want to add Access-Control-Allow-Origin: "*" to the headers so I can download image files remotely via JavaScript.</p>
  
  <p><strong>UPDATE 1</strong></p>
  
  <p>I have the answer for images under the assets folder to change the headers, but now I also need to do the same thing for public images. I tried the same method below, but no luck.</p>
  
  <p>Example url would be</p>
  
  <pre><code>http://localhost:3000/images/stuff.png
  </code></pre>
  
  <p>I tried the Rack MiddleWare, but it doesn't run the call method when going to a public image. I also tried LocationMatch (on a production environment), same no luck.</p>
  
  <p>What do I try for the public images end to change Headers?</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>So, I did manage to get it working via LocationMatch, but the images can not cache. Is there a way to disable image caching via apache?</p>