1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[TIP] Reduce your Website's Bandwidth Consumption by up to 70%!

Discussion in 'Web Hosting' started by youssef93, Apr 3, 2011.

  1. youssef93

    youssef93 Senior Member

    Joined:
    Sep 14, 2008
    Messages:
    828
    Likes Received:
    1,148
    Occupation:
    Student, Part-time Online Marketer
    Location:
    Egypt
    Hey everyone!

    Time to share a bit again. :) This may seem pretty logic to many but many people may really benefit from it. I did this for a client and saved him $$$ of monthly bandwidth costs. If your OK with your current host's memory, CPU, storage...etc BUT your only problem is with bandwidth then read on because you do not need to transfer hosts or anything.

    If you're using a great deal of bandwidth you most likely have lots of images/videos hosted on your server. My client had dozens of images on his sales letter, 600kb++ each. So with regards with images you can do one of these things or both:

    - I like all my images to be PNG. Pretty small sizes and preserves quality. JPEG is also small but not of the same quality as PNG.

    - [This one is the killer] Transfer your images to a dedicated image host and load them from there. This REALLY made my client's website spend peanuts daily on bandwidth. I hear you though: "What if these images go down? How can I trust a third party server?" Read on to find more how you can guarantee 100% image uptime.

    - Move your videos to Vimeo. Reason I say vimeo is that their player looks a lot more professional than youtube when embedded on sales letter. You can also use YouTube of course.


    Now how to maintain 100% image uptime if you're hosting it elsewhere?

    Using a little PHP script I coded for the purpose. What this simply does is allow you to enter URLs for 3 mirrors of each image on a different image host. Every time the page loads, it'll check the first URL and ensure it's alive. If not, it goes to the second mirror and displays the image from there. If not, it uses the third one. Pretty useful and with little twists you can use it for a lot more stuff;)

    Download here:
    Code:
    http://www.mediafire.com/?9fxkw868qxuomll
    Just a zip with 2 php files inside. Core file is "image_functions.php". Other file is just a sample to show you how to use it. Upload both files to the same directory then run "load_image.php".

    How to use?

    1- Upload "image_functions.php" to the same directory as the other files that are gonna use it.

    2- Assuming index.php loads your sales letter and thus your images, at the very top of the file insert this code:

    PHP:
    <?php
    require_once('image_functions.php');
    $host1 "http://host1.com/image.png";
    $host2 "http://host2.com/image.png";
    $host4 "http://host3.com/image.png";
    ?>
    Replace the URLs with the image mirror URLs.

    3- Now in the place were you enter your image URL, place this code:

    PHP:
    <?php loadimage($host1,$host2,$host3);?>
    So overall it'll look something like this:

    PHP:
    <img src="<?php loadimage($host1,$host2,$host3);?>" alt="Test Image" />
    Now when having multiple images, you can insert other variables as well like $host4, $host5, $host6 then simply change this part:

    PHP:
    <?php loadimage($host1,$host2,$host3);?>
    to be $host4, 5, 6 according to the image you're loading.

    May be a little bit tedious to some to initially setup but it gets quite a great peace of mind.

    If you think this whole image mirrors idea is an overkill, then simply use one image host and call it good. I'd recommend wordpress.com. Read more about why I listed wordpress and other image hosts you can use as well at this guy's blog:

    http://www.techieblogger.com/2009/09/free-image-hosting-and-photo-sharing-sites.html

    Hope this helps anyone having bandwidth problems.
     
    • Thanks Thanks x 11
  2. tctuvan

    tctuvan Registered Member

    Joined:
    Jul 14, 2009
    Messages:
    53
    Likes Received:
    0
    Home Page:
    I thinks you should upload to photobucket or imageshack, and dont worry about images bW
     
  3. youssef93

    youssef93 Senior Member

    Joined:
    Sep 14, 2008
    Messages:
    828
    Likes Received:
    1,148
    Occupation:
    Student, Part-time Online Marketer
    Location:
    Egypt
    Pretty much sums up what I was saying. It's just that imageshack has been having some problems and many people can't afford their images going down so the little script above is a bullet proof solution :D
     
  4. banttay

    banttay Junior Member

    Joined:
    Oct 17, 2010
    Messages:
    123
    Likes Received:
    26
    I upload all my images on blogger or picasa to save bandwidth. It is free and much reliable Images loads faster and bandwidth is unlimited.
     
  5. edgematch

    edgematch Elite Member

    Joined:
    May 24, 2010
    Messages:
    2,538
    Likes Received:
    1,949
    Occupation:
    You can never guess!
    Location:
    :noitacoL
    All images hosted on photobucket for years for free and no downtime up to now.
     
  6. youssef93

    youssef93 Senior Member

    Joined:
    Sep 14, 2008
    Messages:
    828
    Likes Received:
    1,148
    Occupation:
    Student, Part-time Online Marketer
    Location:
    Egypt
    That's my recommended route as well. :D. Usually one reliable host would be enough. :)

    Thanks for your input.
     
  7. roamer

    roamer Power Member

    Joined:
    Dec 2, 2008
    Messages:
    500
    Likes Received:
    479
    Occupation:
    Gfx designer, vfx and mgfx
    Location:
    plɹoʍ ǝɥʇ punoɹɐ ƃuıɯɐoɹ
    Nice share. I used to do something very similar for an old website with limited bw, but I just used a single image host and displayed the local file if down, so your solution is better. Thanks for sharing.
     
  8. Entrepreneur

    Entrepreneur Regular Member

    Joined:
    Oct 12, 2007
    Messages:
    438
    Likes Received:
    379
    Amazon is the winner. Always. I'd suggest using them for anything bandwidth intensive.
     
  9. youssef93

    youssef93 Senior Member

    Joined:
    Sep 14, 2008
    Messages:
    828
    Likes Received:
    1,148
    Occupation:
    Student, Part-time Online Marketer
    Location:
    Egypt
    Well, it is when you're delivering massive downloads. But a bunch of images? I wouldn't bother. Besides, amazon services is paid, right? For just hosting images, there are some pretty solid free alternatives with unlimited bandwidth or "unmetered" bandwidth to be more accurate.

    Thanks for your input :)
     
  10. Virus1

    Virus1 Supreme Member

    Joined:
    Dec 13, 2010
    Messages:
    1,326
    Likes Received:
    1,409
    Occupation:
    destroyer of worlds...
    Location:
    Welcome to Black Hat World........................
    Home Page:
    photobucket is metered.... or at least it was the last time i checked....
     
  11. banttay

    banttay Junior Member

    Joined:
    Oct 17, 2010
    Messages:
    123
    Likes Received:
    26
    Yes Photobucket has monthly bandwidth quota, I always reach my bandwidth quota thats why I moved my images to picasa.
     
  12. thedudelady

    thedudelady Registered Member

    Joined:
    Jan 15, 2010
    Messages:
    93
    Likes Received:
    90
    Hi, I name my images for seo with keywords I target as when google index those images they will be found when people search for stuff. You way I will loose traffic as if the images is hosted on my server the traffic will come myway
     
  13. youssef93

    youssef93 Senior Member

    Joined:
    Sep 14, 2008
    Messages:
    828
    Likes Received:
    1,148
    Occupation:
    Student, Part-time Online Marketer
    Location:
    Egypt
    That's a valid point. However, if you can go the wordpress route. Add all the images to a wordpress.com blog and load them from your server. Then, on the blog, use something at the top of the saying "This site only contains images, visit our site HERE" so when traffic lands there, they can still go to your site. Of course it isn't like landing on your main site in the first place but it's a decent solution. :)
     
  14. therealmadhatter

    therealmadhatter Regular Member

    Joined:
    Mar 13, 2011
    Messages:
    247
    Likes Received:
    161
    Occupation:
    Jobless
    Location:
    BHW is my home
    For image hosting one can use Flickr
     
  15. xpwizard

    xpwizard Junior Member

    Joined:
    Nov 6, 2010
    Messages:
    198
    Likes Received:
    122
    Good tutorial for most.

    I would add the following points though:

    #1 - Just because you've chosen PNG output doesn't mean that it's fully optimized yet. You can output an optimized file in photoshop using the "save for web" feature, or by uploading your PNG to an online optimizer such as punypng.

    #2 - You need a form of error handling. If one host goes down then the script will always check that host adding more execution/load time. Instead you should have the script remove dead hosts and send off a quick mail to the webmaster letting them know that host is down.

    #3 - Calling another webhost via fsocket every page load isn't going to help with load speed which is what most webmasters want. Instead create a master file that's called by cron every 30min and will either fwrite the host to the landing page, or have the landing page call a DB with the chosen host.

    #4 - If you don't like the Youtube skin, then just use the google/youtube api and create a custom player/skin...
     
    • Thanks Thanks x 1
  16. youssef93

    youssef93 Senior Member

    Joined:
    Sep 14, 2008
    Messages:
    828
    Likes Received:
    1,148
    Occupation:
    Student, Part-time Online Marketer
    Location:
    Egypt
    Thanks for your input.

    #1: Yeah good point. Well I do use the photoshop save for web option but thanks for pointing that out for others as well.

    #2: Thought exactly of that. However, thought that this, with many images, may spam the death out of the webmaster so let it slide.

    #3: That's one good point I'm thinking of implementing. However, it's a lightweight script that's not optimized to deal with a very large amount of images. It's just something to get things going. If many people want to use it, I may go ahead and add other features. :)

    Thanks for your input. Oh and if you'd like to improve it and repost feel free to do so.
     
  17. GivingBack

    GivingBack Newbie

    Joined:
    Apr 6, 2011
    Messages:
    13
    Likes Received:
    1
    If you can't cover your image hosting costs you're monetizing the site wrong. Sites look and feel more professional if it's all hosted on the same server.
     
  18. AlexaR

    AlexaR Junior Member Premium Member

    Joined:
    Apr 5, 2011
    Messages:
    166
    Likes Received:
    76
    Occupation:
    Ghostwriter
    Location:
    Mexico
    Home Page:
    i dont really have bandwidth problems but your post and script helped me with something else, so wanted to say thank you :)
     
  19. myniche

    myniche Junior Member

    Joined:
    Feb 13, 2009
    Messages:
    112
    Likes Received:
    51
    Great tip and something to think about in the future.
     
  20. Hostwinds

    Hostwinds Power Member UnGagged Attendee Enterprise Member

    Joined:
    May 17, 2010
    Messages:
    766
    Likes Received:
    544
    Occupation:
    C.E.O.
    Location:
    Oklahoma
    Home Page:
    TRUTH

    However you will see some speed increases from hosting from mutliple hostnames. LOL Its like a ghetto ass CDN