Wednesday, November 22, 2006

Testing Ruby on Rails Page Caching - Good article.

Something I learned recently: Rails doesn't cache pages in development mode, only in production mode. This is a tricky little gotcha if you're testing page caching. I tend to agree that we shouldn't cache pages in development mode, but I wish there was something that made it clear the pages aren't getting cached.

For expiring cached pages, I started off with looking at addicted_to_caching, which is excellent, by the way, but it wasn't quite sophisticated for what I needed, so I wrote my own custom sweeper. We need a better solution for this, a plugin that you can register view pages with models, and figure out when you save a model, what views depend on that model.

I was thinking about writing a plugin that would automatically determine these dependencies, it would generate something like a Makefile, with models and views related by dependencies.