Fragment caching and sweeping strategy

Rails provides three types of caching techniques: page caching action caching fragment caching The rails_guides_on_caching is the best place to know how it works. This article is to demonstrate fragment caching the Rails Way with various data-stores and clearing those cached fragments on ActiveRecord callbacks on CRUD operations. Rails ActiveSupport::Cache::Store is responsible to do all the read and write operations. 1. The setup By default caching is disabled in rails. You will find the following config commented out in production.rb # Use a different cache store in production # config.cache_store = :mem_cache_store You