...

/

Caching of Partial Results

Caching of Partial Results

Learn to cache the results of partials.

We'll cover the following...

If everything goes as planned, this page will definitely be a high-traffic area for the site. To respond to requests for this page, we’d need to fetch every product from the database and render each one. We can improve on that. After all, the catalog doesn’t change that often, so there’s no need to start from scratch on each request.

So we can see what we’re doing, we’re first going to modify the configuration for the development environment to turn on caching. To make this easy, Rails provides a handy command to toggle caching on and off in the development environment:

depot> bin/rails dev:cache

Note that this command will cause the server to automatically restart.

Next, we need to make a plan. Upon consideration, we only need to re-render ...