menntarra_34 Posted August 29, 2011 Share Posted August 29, 2011 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 https://forums.phpfreaks.com/topic/245972-ping-ad-server/ Share on other sites More sharing options...
ZulfadlyAshBurn Posted August 29, 2011 Share Posted August 29, 2011 what you mean acting strangely?! Link to comment https://forums.phpfreaks.com/topic/245972-ping-ad-server/#findComment-1263254 Share on other sites More sharing options...
menntarra_34 Posted August 29, 2011 Author Share Posted August 29, 2011 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 https://forums.phpfreaks.com/topic/245972-ping-ad-server/#findComment-1263279 Share on other sites More sharing options...
voip03 Posted August 29, 2011 Share Posted August 29, 2011 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 https://forums.phpfreaks.com/topic/245972-ping-ad-server/#findComment-1263291 Share on other sites More sharing options...
menntarra_34 Posted August 29, 2011 Author Share Posted August 29, 2011 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 https://forums.phpfreaks.com/topic/245972-ping-ad-server/#findComment-1263311 Share on other sites More sharing options...
menntarra_34 Posted August 30, 2011 Author Share Posted August 30, 2011 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 https://forums.phpfreaks.com/topic/245972-ping-ad-server/#findComment-1263365 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.