Skip to content

ViliusLuneckas/rails-cache-inspector

Repository files navigation

Rails cache inspector

Dead simple tool for visual debugging of fragment cache.

Installation

Add this line to your application's Gemfile:

gem 'rails-cache-inspector', group: :development

Usage

Configure highlighting

# config/initializers/rails_cache_inspector.rb

RailsCacheInspector.configuration.highlight_with = { 
  style:      'filter: sepia(1)',  # default – 'filter: sepia(1)'
  class_name: 'is-cached'          # default - ''
}

Configure rails application

Make sure caching is turned on in development environment

# config/environments/development.rb

config.action_controller.perform_caching = true

In action

Cached fragments have blur filter in the demonstration below. It's easy to identify potentially slow parts of the page and make it fast again.

visual-debugging