Caching Rails 3 on Heroku
To learn about caching, I used a few different resources.
The three basic types of caching are:
- page caching – mainly for static pages, it will not work if any filters are applied to the controller of the page (ie authorizations)
- action caching – typically what you’d used to cache a page if they have filters
- fragment caching – allows for caching of blocks of html on a page (if you can’t cache the whole page) or for partials
Since I’m on Heroku, the first place to learn was Heroku’s documentation. It’s important to read the Heroku docs first because some standard Rails functions work differently on Heroku’ platform. Mainly, for page caching (uses different syntax than standard rails) and action caching (mostly dependent on memcache, so you need to set your app up accordingly).
Overview of caching on Heroku
There’s also a Rails Guide on Caching (just remember to ignore page caching part):
However, the most extensive (and useful) one for me was from Adam Hawkins at (especially for fragment caching):
I also needed to learn about sweepers, in order to observe for changes that would impact another controller’s pages. This Stack Overflow post helped me learn to put the sweeper in with the models and to ensure that I updated the correct controller: