Go back to the main page

Suppressing and disabling cache miss output when using Dragonfly

This article is over 2 years old. Proceed with caution.

Regards ♨ – Minimul


Rack-cache from Dragonfly

Dragonfly adds in Rack-cache to the middleware by default. Therefore, if you run rake middleware in a Dragonfly initialized environment you will see the following:

use Rack::Cache
use Dragonfly::Middleware

Rack-cache outputs to $stderr and its verbose setting is true by default so these cache-miss messages are visible during a WEBrick or similar session. Since the Capybara javascript driver uses WEBrick to test against these cache-miss will flood the screen.

Beware of using quick setup

If you are using the quick Dragonfly setup in require 'dragonfly/rails/images' based off of the docs you may not be having success with suppressing the cache-miss messages using some of the common online prescriptions. Using the quick setup inserts all of the defaults as listed in the section "Setting up the more explicit way". If you try overriding the verbose setting you may not have much success because the require 'dragonfly/rails/images' will keep inserting a Rack-cache with verbose: true into the middleware.

Just use the Dragonfly explicit setup

Simply use the explicit setup and mark verbose: false or if you just want to suppress the cache-miss messages during a Capybara javascript run then use something like verbose: Rails.env.test? ? false : true. Don't use the quick setup.

Comment on this article?