Configuring Our Resolver for Production
To ensure the template lookup is fast in production, Rails provides some caching conveniences. Let’s explore those conveniences so we understand how to enable caching for our templates, and the strategies available to us to expire this cache whenever a template is saved to the database.
As mentioned earlier, Rails gives our resolver a cache_key through the find_all method. Our first stop is to learn why Rails creates this cache key and how our resolver uses it.
The Resolvers Cache
As we saw in the code, ActionView::Resolver’s find_all method automatically caches templates using the cached method. The cache is created on initialization and referenced by the instance variable @cached. The resolver ...
Get Crafting Rails 4 Applications, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.