Reputation: 10898
I have my application in my development server, now i am planning to implement CDN for all the assets used in the application.
How can i do this with Rails? is there any available gem for doing this or any manual configuration has to be done?
I tried googling this topic but found suggestions mostly for Cloud front Heroku.
Note : I am using Ngnix in my server and going to buy CDN from a different Vendor.
Upvotes: 0
Views: 2697
Reputation: 10898
Found the solution
Steps to implement custom cdn url
1) Set the asset path in config/environment/production.rb
config.action_controller.asset_host = "http://cdn.mydomain.com"
2) Rename all the styles and js files as shown below (if you miss this step, the asset_path tag mentioned in step 3 will not work)
assets/stylesheets/styles.css => assets/stylesheets/styles.css.erb
3) Update the stylesheet code as shown below
background: url(<%= asset_path "sprite/top-tile.png" %>) repeat-x scroll 0 -77px transparent !important;
Note : But make sure you set Access-Control-Allow-Origin "* or cdn url" in NGINX. Only then you can access your font family from cdn url as Firefox and IE doesn't allow this by default.
Upvotes: 3