开发者

HTTP redirect fallback

Is there a way to provide fallback URL when HTTP redirect times out? What I'm trying to achieve is that when I hit the original url, I would respond with HTTP redirect (300, 307?) giving the browser new URL and the fallback URL in case the new URL times out?

I was also considering开发者_JS百科 doing this client side but it just does not seem to be very effective (in terms of speed, client support). What I would do is probably have a tiny 1x1px image on each server, try loading it and then check with javascript which server is up and redirect there.

Any other ideas? Thanks


I think this can be done only through JavaScript. You could do a quick server side test before sending out the redirect, but that would not be reliable - especially if the servers are in the same server farm.

The most reliable thing would surely be to have a JavaScript, have that make a quick Ajax request (HEAD only) to the server, and redirect on success. If it fails, try the next server... and so on.

Is this really necessary, though? If the target server has so many outages that you need to react to them programmatically, it may be worth looking into relocating the server (or doing whatever is needed to fix the outages).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜