Please Do Not Use Asset Sync
Last updated 28 October 2015
Using Asset Sync can cause failures. It is difficult to debug, unnecessary, and adds extra complexity. Don’t use it. Instead, use a CDN.
The concept of keeping your code DRY is more than good practice. It allows you to have single, authoritative places where you store information. If you need to change that information, you only need to change it in one place. In contrast, with
asset_sync although your “canonical” copy of assets is in our source control, you are relying on a third-party store of assets. What happens if someone has a failed deploy after assets get synced? What if someone modifies a file in the S3 bucket? Instead of fixing one copy of assets, now you must fix two.
If you’re debugging inside of a dyno with
heroku run bash and you run
rake assets:precompile this doesn’t just modify your local copy. It actually modifies the copy on S3 as well. This goes back to canonical stores, which can be bad because all of your assets become wrong and you don’t know why. The sync part of
asset_sync can also fail if there’s a glitch in the network. What if you only write part of a file, or only half of your assets are synced? These things happen.