Posted 5 months ago. Visible to the public. Repeats.

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:

Copy
# 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:

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

In Capistrano 2 you need to link the directory manually.

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Dominik Schöler
Last edit:
21 days ago
by Michael Leimstädtner
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 cookies to improve usability and analyze traffic.
Accept or learn more