|
|
#1 |
|
Senior Member
Join Date: Sep 2003
Posts: 132
|
A Code That Will Swap Hosts
Hi evryone just wondering if any of you knows a way that if a host is down that is hosting a image for your website. The website will detect this and swap hosts of the image to another host containing the same image
any help would be gratly appriciated Emok |
|
|
|
|
|
#2 |
|
Forum King
Join Date: Jan 2002
Location: the nether reaches of bonnie scotland
Posts: 13,378
|
the problem with this is that it requires you to test the host by seeing if it times out. so if you do detect that the host is down, it'll add a good 5-10 seconds to the page loading time. you'd be better off adding a link that says "alt. source" or something to the bottom.
it can be done in PHP, but i don't know how - i've seen it done (and added code to do it myself) before. but, as i say, it's not a practical thing to really do... |
|
|
|
|
|
#3 |
|
Court Jester
(Forum King) |
Say your local website is host-a.com, and your image is mirrored as http://host-b.com/img.gif, http://host-c.com/img.gif and http://host-d.com/img.gif.
Then you can set up a script like this on host-a.com: PHP Code:
Adapt accordingly. Ideas: (1) Use GET variables to make that script grab any named mirrored file; (2) Build some intelligence into that script to discover the file type and output suitable content-type headers; (3) Randomise the order in which the mirroring hosts are contacted so you get load-balancing, sort of. You still have to set up the mirroring yourself, of course. |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Sep 2003
Posts: 132
|
Cherz Evryone
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|