Did fragment caching (using memcahe) in the Rails app today. Here are the things:
– Added the following in the view:
<% cache “my_cache_partial”, :expires_in => 1.hour do %>
<%= render :partial => “partials/my_partial” %>
<% end %>
– Added the gem ‘dalli’
– Then added the following in development.rb(and all other environemnts)
config.cache_store = :dalli_store, ‘localhost:11218’
DALLI_STORE = ‘localhost:11218’
config.action_controller.perform_caching = true
Note*: expire_in will not work without memcache!