In my production.rb
I've set this:
# Enable serving of images, stylesheets, and JavaScripts from an asset server
config.action_controller.asset_host = "http://myassets.com"
And the images, js and stylesheets are loading fine from my CDN (assets server)
but what if someday this asset servers fails? and it returns a 404?
Because in my assets server (CDN) I have configure a pull zone
, the content is still available from /assets/..
.
Is there any fallback or how can I make a fallback so when my assets server
fails or return error my application loads assets from /assets/
inside the application?
The clean it removes the old versions of the precompiled assets while leaving the new assets in place. Show activity on this post. rake assets:clean removes compiled assets. It is run by cap deploy:assets:clean to remove compiled assets, generally from a remote server.
The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass, and ERB.
To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.
Sprockets is a Ruby library for compiling and serving web assets. Sprockets allows to organize an application's JavaScript files into smaller more manageable chunks that can be distributed over a number of directories and files.
production.rb
config.action_controller.asset_host = Proc.new { |source, request, asset_path|
if some_condition
"http://myassets.com"
else
asset_path
end
}
For more info, see AssetTagHelper
Edit
I don't think this precaution is worth the extra load/added requests to your application. If you were building a large application with failover servers to provide high availability, assets would be yet another thing you'd accommodate for with that redundancy. If you're hosting your stuff on the cloud through a service like AWS or Rackspace, I think you're good on availability and you shouldn't worry about the issue. This approach almost completely negates the benefit of caching assets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With