O'Reilly logo

Crafting Rails 4 Applications, 2nd Edition by José Valim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required