Skip to content

[Recipe] fast_assets

afunction edited this page Oct 7, 2014 · 4 revisions

If you have multiple app servers, or separate servers between app and web roles, or your assets on CDN, you may concern about which server is resiponsible to compile assets and upload to servers.

This recipe will use least resource to compile assets and upload to remote server. it combine Gem - AssetSync and compile assets locally instead default capistrano precompile task.

Without CDN

You don't have to configure it, just add fast_assets recipe in your deploy.rb, it will compile assets locally, and upload manifest file to servers of app role and assets files to servers of web role.

With CDN

After include fast_assetsrecipe, you have to config your CDN access token, it will use asset_sync to upload your assets to cloud, the example below using AWS S3:

# CDN
set :cdn, {
  fog_provider: 'AWS',
  fog_directory: 'your_bucket_name',
  aws_access_key_id: 'your aws id', # create from IAM
  aws_secret_access_key: 'your aws secret token',
  fog_region: 'ap-northeast-1' # bucket region
}

Once you choose upload assets to CDN, deploy task will NOT upload asset files to your web server, because web dose not need it. For more details about CDN configuration, please visit: https://github.com/rumblelabs/asset_sync

Source: https://github.com/afunction/visionbundles/blob/master/lib/visionbundles/recipes/fast_assets.rb