Masatoshi Nishiguchi

Caching in rails 5

Enabling/disabling caching in development environment

Use the following commands:

$ rails dev:cache
Development mode is now being cached.
$ rails dev:cache
Development mode is no longer being cached.

Fragment Caching

<% @products.each do |product| %>
  <% cache product do %>
    <%= render product %>
  <% end %>
<% end %>
<%= render partial: 'products/product', collection: @products, cached: true %>

References