What is caching in Rails and what types are available?

Answer

Rails supports several caching strategies: Page caching — caches the entire response as a static file (Rails 4+ extracted to a gem). Action caching — caches after running filters (also a gem). Fragment caching — caches portions of views with <% cache @post do %>...<% end %>; the most commonly used. Low-level cachingRails.cache.fetch("key") { expensive_calculation }. SQL caching — automatic within a request (same query twice hits cache). Cache stores: MemoryStore, FileStore, MemCacheStore, RedisCacheStore. Configure with config.cache_store.