{"id":6741,"date":"2014-04-23T02:02:56","date_gmt":"2014-04-23T02:02:56","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/23\/how-to-cache-files-over-1mb-with-rack-cache-on-heroku-collection-of-common-programming-errors\/"},"modified":"2014-04-23T02:02:56","modified_gmt":"2014-04-23T02:02:56","slug":"how-to-cache-files-over-1mb-with-rack-cache-on-heroku-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/23\/how-to-cache-files-over-1mb-with-rack-cache-on-heroku-collection-of-common-programming-errors\/","title":{"rendered":"How to cache files over 1MB with rack\/cache on Heroku?-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m using a combination of Dragonfly and rack\/cache hosted on Heroku.<\/p>\n<p>I&#8217;m using Dragonfly for uploaded assets. Thumbnails are processed on-the-fly and stored in rack\/cache for fast delivery from memcached (via the Memcachier addon).<\/p>\n<p>Regular static assets are also cached in memcached via rack\/cache.<\/p>\n<p>My problem is that any uploaded files over 1MB are causing a 500 error in my application.<\/p>\n<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]\n2013-07-15T10:38:27.052255+00:00 app[web.1]: cache: [GET \/media\/BAhbBlsHOgZmSSIdNTA3Njk3ZWFiODBmNDEwMDEzMDAzNjA4BjoGRVQ\/WTW_A5Flyer_HealthcareMedicalObsGynae_WEB.pdf] miss, store\n2013-07-15T10:38:27.060583+00:00 app[web.1]: !! Unexpected error while processing request: undefined method `each' for nil:NilClass\n<\/code><\/pre>\n<p>Memcache has a limit of 1MB, so I can understand why my asset was not cached, but I would rather it didn&#8217;t break serving assets.<\/p>\n<p>I&#8217;m not even sure where this error is coming from. Presumably from one of the other rack middlewares?<\/p>\n<p>Increasing the maximum file size doesn&#8217;t seem to have have any affect.<\/p>\n<pre><code>config.cache_store = :dalli_store, ENV[\"MEMCACHIER_SERVERS\"].split(\",\"), {\u00ac\n  :username        =&gt; ENV[\"MEMCACHIER_USERNAME\"],\u00ac\n  :password        =&gt; ENV[\"MEMCACHIER_PASSWORD\"],\u00ac\n  :value_max_bytes =&gt; 5242880 # 5MB\u00ac\n}\n<\/code><\/pre>\n<p>Long term, I know that moving this sort of asset off of Heroku is a sensible move, but that won&#8217;t be a quick job.<\/p>\n<p>What can I do to serve these assets on Heroku in the meantime without errors?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m using a combination of Dragonfly and rack\/cache hosted on Heroku. I&#8217;m using Dragonfly for uploaded assets. Thumbnails are processed on-the-fly and stored in rack\/cache for fast delivery from memcached (via the Memcachier addon). Regular static assets are also cached in memcached via rack\/cache. My problem is that any uploaded files over 1MB are causing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6741","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6741"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6741\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}