Add cache_if! to conditionally cache JSON fragments

I've found myself in the situation of needing this kinda often. Since Rails supports it, I think it should also be here for symmetry.