Have you ever been slashdotted, Dugg, or attacked by the web 2.0 clones? Have you had the bill from your hosting supplier asking for £10/Gigabyte overbandwidth?
Well, it can be very annoying. Here is the best idea ever for a cheapass way of getting around using any bandwidth... the Coral Cache failover.
The basic premise of this HOWTO is to set up your website to use someone elses bandwidth instead of your own. You do this on the sly, and generally without too many people noticing.
So... what to do:
You will need to know when you have been web2.0-ko'd. Bandwidth detection depends on what platform and technology you are using on your website. I am not going to go into any code examples of how to detect bandwidth, as this is a fairly non trivial task for every platform.
What I am going to do is suggest a couple of means of detecting bandwidth loading.
Check your referrer logs using a cron based shell script. This will give you stats of how often a site has been referred to your page. If you get a lot of hits on one particular page, you can trigger a threshold to failover.
Method 2: My preferred method.
Use a php script to store the referrers from the header. Use a cron script to check these referrers using a MYSQL query. This will give you the referrers per page. You can also write a script to calculate the page size, and compare against your bandwidth usage so far. Once you hit your set threshold, failover.
Protecting you wallet
This is where it gets fun. In order to save you from going slowly bankrupt by those ad blocking slashdot monkeys eating your bandwidth, you need to failover. What I mean by this is to get your website to redirect to Coral Cache.
You have a couple of ways of doing this, as detailed.
If you have a website control panel that allows your domain to be redirected, you can trigger a script to redirect your entire domain to "yourdomain.nyud.net:8090" This will instantly cache your site, as well as redirecting all traffic to the cached version.
If you have a hosting platform that has webspace, and no redirect facility, you can use a frame, or a hidden iframe. All you have to do is serve up "yourdomain.nyud.net:8090" in the frame. If you use a hidden iframe, you will retain your domain url at the top, but have the ability to browse in the iframe.
This essentially is an automated redirect to a cached version of your website.
Idea courtesy of Daniel Elkan.