Nginx adds strange characters using rails/memcached_pass

After upgrading a few gems recently, I found that the content returned from the nginx memcached_pass directive always had a few strange characters prepended. After some investigation it seems that this is caused by rails ‘marshalling’ the data. If you’re using a memcached set command such as Cache.set(key, content, time_to_live) You need to add an extra argument to force rails to cache the raw data instead of marshalling it : ...

December 23, 2008 · 1 min · Dave Perrett

memcaches_page plugin for Rails

This plugin is very similar to the built-in Rails ‘caches_page’ functionality, except it caches to memcached rather than a file. It relies on the ‘memcached_pass’ nginx directive to serve pages directly from memory if possible, and only passes to rails if necessary. On my server I’ve seen a 75% reduction in Ruby memory usage using this technique. ...

December 3, 2008 · 3 min · Dave Perrett