Posted over 3 years ago. Visible to the public.

Capistrano: Speeding up Sprockets' asset compile during deploy

Remember How to skip Sprockets asset compile during Capistrano deployment and Automatically skipping asset compilation when assets have not changed? Turns out there is an even better way to speed up Capistrano deployments with asset compilation – and it's even simpler.

Adding the Sprockets cache directory to shared directories

Sprockets is the library behind Rails' asset pipeline. It keeps a cache of already compiled files, so when a single file changes, it only needs to rebuild that one. This is exactly what makes asset compilation so fast in development. We're gonna leverage the cache for deployments now.

In Capistrano 3, add tmp/cache/assets/sprockets to your linked directories:

# deploy.rb set :linked_dirs, %w[log public/system tmp/cache/assets/sprockets …]

If you want to do this for a specific stage only, do this instead:

# deploy/staging.rb append :linked_dirs, 'tmp/cache/assets/sprockets'

In Capistrano 2 you need to link the directory manually.

Your development team has a full backlog of feature requests, chores and refactoring coupled with deadlines? We are familiar with that. With our "DevOps as a Service" offering, we support developer teams with infrastructure and operations expertise.

Owner of this card:

Dominik Schöler
Last edit:
12 months ago
by Dominik Schöler
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Dominik Schöler to makandra dev
This website uses short-lived cookies to improve usability.
Accept or learn more