Re:Amazon DNS error
by cjreyes on Wednesday November 26, 2014 @07:57PM
(#8665471)
Is there a RoR Gem / configuration that will serve assets locally if an external asset host name doesn't resolve or times out?
[ Parent
| on HN ]
There isn't, but there's a frontend library that you can use to add fallbacks to <script> tags:
Not a gem, but from jQuery days:
<script> window.jQuery || document.write("<script src='js/jquery-1.10.2.min.js'>\x3C/script>")</script>
Re:Amazon DNS error
by jacobsenscott on Wednesday November 26, 2014 @10:16PM
(#8665830)
You can assign a proc to config.asset_host, so you could easily do it -
config.asset_host = -> {
cdn_up? ? "http://mycdn.com" : "http://mydomain.com"
}
Re:Amazon DNS error
by lukeschlather on Wednesday November 26, 2014 @08:50PM
(#8665621)
It's a decent idea, but it would be better to do client-side. For this sort of event, knowing that the name resolves on the server doesn't give you any confidence it will resolve for the client.
What would be really nice is if you could specify a fallback host in your DNS prefetch, and the browser would make it "just work."
Exactly, if a POP for Australia is down but works in Germany, better to serve this on the client side.