May 2025
Intermediate to advanced
270 pages
6h 55m
English
While counter_cache is really useful, the most common technique that comes to mind when talking about caching in Rails is using it directly on the body of the response—typically the view or the body of a JSON API. This is something different from what you have been doing so far. We are not caching database queries anymore; we are caching actual responses. Next, you will explore how to use this kind of caching.
This time, the endpoint that you will work on is /films. In the controller, you will find a quite straightforward logic:
| | def index |
| | @films = Film.includes(:language, :stores) |
| | end |
So far, so good: there is nothing that looks obviously wrong ...
Read now
Unlock full access