Rails 3 - Is there a rollback when an asset service fails from an asset server?

In my production.rb I installed this:

 # Enable serving of images, stylesheets, and JavaScripts from an asset server config.action_controller.asset_host = "http://myassets.com" 

And images, js and style sheets load fine from my CDN (resource server)

but what if someday these resource servers fail? and he returns 404?

Since I configured a pull zone on my resource server (CDN), the content is still accessible from /assets/..

Is there any recession or how can I make a backup, so when my assets server error or return error does my application load assets from /assets/ inside the application?

+4
source share
2 answers

production.rb

 config.action_controller.asset_host = Proc.new { |source, request, asset_path| if some_condition "http://myassets.com" else asset_path end } 

See AssetTagHelper for more information.

Edit

I do not think that this precaution deserves additional loads / added requests to your application. If you were building a large application with fault tolerance servers to ensure high availability, assets would be another thing you could handle with this redundancy. If you place your stuff in the cloud using AWS or Rackspace, I think you are well versed in accessibility and you should not worry about this issue. This approach almost completely negates the benefits of asset caching.

+3
source

You can study the following directive

 ActionController::Base.asset_host = Proc.new { |source, request| if #code to check if CDN is alive "CDN Url" else "/public/assets/" end } 
0
source

All Articles