Jump to content

Ping AD server


menntarra_34

Recommended Posts

Hello, please can anyone advise a right solution on how to avoid my site acting strangely when one of my AD companies stops to function.

I mean there are downtimes for AD servers as well, and i'm wondering what is the best solution? Can i load ads on my pages separately, so i mean lastly? They are all over my page so i guess i can't do it. Or is it better to ping ad server and wrap these ADS around PHP if functions, which ping these servers?

If you have a solution , which is most effective, please tell me.

Link to comment
Share on other sites

well i mean, if one of those ad servers are down, my site stops loading, cause it is trying to load the ADS, but because of the ADSERVER being slow/hanging at some points, it also slows down my site...

yesterday, i did wait for 2 minutes, and my site stopped at a point where an AD should load. Then i checked the AD company's server and i couldn't reach it...

 

So basicly they must be having high load or something like that, but in these cases i don't want it to affect MY site's performance... What could be the best solution?

Link to comment
Share on other sites

Use get_headers or url exists method to check ADS url are available

 

get_headers

$file = http://www.phpfreaks.com/forums/index.php?topic=342689.0; 
$file_headers = @get_headers($file); 
if($file_headers[0] == 'HTTP/1.1 404 Not Found') 
{ $exists = false; echo "URL not found"; } 
else 
{ $exists = true;  echo "URL found";     } 

url_exists

function url_exists($url) {
    if (!$fp = curl_init($url)) return false;
    return true;
}

Link to comment
Share on other sites

I found something like this:

 

It should be as fast as it can be, i wonder if it can hang as well, meaning if the AD server is online, but under high load, so basicly answering, but connection is crappy.

 

 

function url_exists($url)
{


    $handle   = curl_init($url);

    if (false === $handle)
    {
        return false;
    }

    curl_setopt($handle, CURLOPT_HEADER, false);
    curl_setopt($handle, CURLOPT_FAILONERROR, true);  // this works
    curl_setopt($handle, CURLOPT_HTTPHEADER, Array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15") ); // request as if Firefox   
    curl_setopt($handle, CURLOPT_NOBODY, true);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, false);

    $connectable = curl_exec($handle);

    curl_close($handle);  

    return $connectable;
}

 

 

 

Link to comment
Share on other sites

I think this is the solution i found:

 

Deferring ad loading on your pages to avoid unnecessary outages:

 

1. I put my deferredcontent.js code that I wrote in the head tag

<script type=”text/javascript” src=”/js/deferredcontent.js”></script>

2. I added an onload=”relocateDeferredContent();” to the body tag

3. I put an empty div tag where I ultimately wanted the content to end up. E.g <div id=”adleaderboard”></div>

4. I put the deferred content in a display:none div just before the closing body tag at the very end of the page and put each block of code I wanted to relocate in a div with an id of defer-IDFROMSTEP3

 

<div style=”display:none”>

<div id=”defer-adleaderboard”>

[Ad code goes here]

</div>

</div>

 

 

 

 

 

thanks to the man who posted it here:

http://gabrito.com/post/deferring-ad-loading-on-your-pages-to-avoid-unnecessary-outages

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.