
Getting Started With Caching in Ruby on Rails
Your Rails app is slow. You know it. Your users know it. And the worst part is, half the time your app is doing the exact same work over and over again, fetching the same data, rendering the same partials, running the same queries. Caching fixes that. You tell Rails "hey, remember this," and the next time someone asks for it, Rails hands it right back without breaking a sweat. We're going to walk through every caching strategy Rails gives you out of the box. Fragment caching, Russian doll caching, low-level caching, collection caching, and how to configure your cache store. By the end of this, you'll know exactly which type of caching to use and where. Enable Caching in Development Before we do anything, caching is turned off in development by default. You need to flip it on or you're going to sit there wondering why nothing is working. Run this in your terminal: bin/rails dev:cache You should see: Development mode is now being cached. That's it. Run the same command again to toggle it
Continue reading on Dev.to
Opens in a new tab



