So I currently have too many assets to push to my free heroku account. I am currently hosting them on a hostgator server which is problematic as, by making a remote request for each image, and the server itself not being of the nature of say Amazon CloudFront which expedites and caches things explicitly for CDN, it visibly loads all the images all slow-like in the DOM. My question is, how can I serve my assets through CloudFront without pushing them to my heroku account?
Best How To :
The best solution is to create a custom deployment script that has a step specifically for uploading your assets to S3, then serve the assets from S3 via CloudFront.(have a look at https://github.com/rumblelabs/asset_sync for ideas)
- Add your assets to your .gitignore
- Set your asset host correctly in your production.rb file
- Step 1 in deploying is copy changed assets to your S3 bucket in the same folder structure that rails expects
- Step 2 in deploying is your push to repo with the standard command
git push heroku master -- which will not push your assets if they are ignored correctly.