I have managed to turn my work at gravatar caching into a little plugin for Mephisto. Its available to install via subversion like so:
ruby script/plugin install http://svn.hiddenloop.com/public/plugins/mephisto_gravatar_cache
You can browse the source code and the README file, which describes how to install and configure it. Although the plugin will work out of the box with it’s default settings.
Given the nature (and newness) of the Gravatar service, its (highly) likely that they may change their usage instructions again. I originally came across some gravatar caching code from a Daniel Haran – it worked with the old gravatar API, which is no longer available.
This new plugin works in a similar way (wget’ing the images) – however – to check an email has a gravatar at all, a request is made to gravatar.com (with a default no-gravatar image). If a 301 (redirect) is found on this request – it is assumed that the user has no image to fetch. The plugin also includes a rake task (for use in a cron job), image expiry time and other configurable class settings for caching options.
While this plugin is a Mephisto Gravatar Cache plugin – with a little modification it could work for any Rails application. The rake task ‘cache_gravatars’ would need to be modified, and a call to cache_gravatar made on any email addresses.
I have tried to comment my code as best as possible, to encourage further development. Please report all bugs and/or submit patches to me at this post. Your comments, criticisms and thoughts are welcome.
- What is Gravatar? – find out here
- More Mephisto Plugins
- Original Gravatar Caching work by Daniel Haran – the older gravatar API
—Update – Curtis at millarian.com has recently played around with this plugin and fixed some bugs. I’ll be sure to update the repository soon and add some more tests. This was my first plugin release and something I coded rather hastily.


