title: How to cache files over 1MB with rack/cache on Heroku?
body: <p>I'm using a combination of <a href="http://markevans.github.io/dragonfly/" rel="noreferrer">Dragonfly</a> and <a href="http://rtomayko.github.io/rack-cache/" rel="noreferrer">rack/cache</a> hosted on Heroku.</p>
  
  <p>I'm using Dragonfly for uploaded assets. Thumbnails are processed on-the-fly and stored in rack/cache for fast delivery from memcached (via the <a href="https://addons.heroku.com/memcachier" rel="noreferrer">Memcachier addon</a>).</p>
  
  <p>Regular static assets are also cached in memcached via rack/cache.</p>
  
  <p>My problem is that any uploaded files over 1MB are causing a 500 error in my application.</p>
  
  <pre><code>2013-07-15T10:38:27.040992+00:00 app[web.1]: DalliError: Value too large, memcached can only store 1048576 bytes per key [key: d49c36d5db74ef45e957cf169a0b27b83b9e84de, size: 1502314]
  2013-07-15T10:38:27.052255+00:00 app[web.1]: cache: [GET /media/BAhbBlsHOgZmSSIdNTA3Njk3ZWFiODBmNDEwMDEzMDAzNjA4BjoGRVQ/WTW_A5Flyer_HealthcareMedicalObsGynae_WEB.pdf] miss, store
  2013-07-15T10:38:27.060583+00:00 app[web.1]: !! Unexpected error while processing request: undefined method `each' for nil:NilClass
  </code></pre>
  
  <p>Memcache has a limit of 1MB, so I can understand why my asset was not cached, but I would rather it didn't break serving assets.</p>
  
  <p>I'm not even sure where this error is coming from. Presumably from one of the other rack middlewares?</p>
  
  <p>Increasing the maximum file size doesn't seem to have have any affect. </p>
  
  <pre><code>config.cache_store = :dalli_store, ENV["MEMCACHIER_SERVERS"].split(","), {¬
    :username        =&gt; ENV["MEMCACHIER_USERNAME"],¬
    :password        =&gt; ENV["MEMCACHIER_PASSWORD"],¬
    :value_max_bytes =&gt; 5242880 # 5MB¬
  }
  </code></pre>
  
  <p>Long term, I know that moving this sort of asset off of Heroku is a sensible move, but that won't be a quick job.</p>
  
  <p>What can I do to serve these assets on Heroku in the meantime without errors?</p>