Is it possible to test when a site has propagated?

I am in the process of changing web hosting…

I know there are numerous web pages that show site propagation…

I am curious to know if it is possible to add additional index.php script to email, create a file or some method to register when the site is available on the new server.

1 Like

I’ve used https://whatsmydns.net in the past. It shows results from all over the world.

1 Like

Would the PHP function dns_get_record() help, John?

Edit:
You could write a cronjob to test the DNS records and email you when they change. Of course, it may have propagated by the time you finish the script! :shifty:

1 Like

@Gandalf, Many thanks.

I checked PHP dns_get_record() and used the following:

PHP gethostbyname()

PHP Function:

# http://php.net/manual/en/function.gethostbyname.php
function sites() 
{
  $result = NULL;

  ##  SITES PROPAGATED 
  if( isset($_GET['propagated']) ):
    $sites = [
      'example.com',
      'site-001.com',
      'site-002.com',
      'site-003.com',
      'johns-jokes.com',
      'amazon.com', 
      'bing.com', 
      'facebook.com',
      'google.com', 
      'sitepoint.com',
      'yahoo.com', 
    ];
    # GET STATUS 
      foreach($sites as $id => $site):
        $ipn = gethostbyname($site);
        if('139.162.244.63' === $ipn):
          $ok[] = ' <a href="//' .$site .'">' .$site .'</a>';
        else:
          $bad[]  = '<td> <a href="//' .$site .'">' .$site .'</a> </td>'
                  . '<td>' .$ipn .'</td>';
        endif;  
      endforeach;

    echo '<dl class="clb w88 mga bgs tal dib">';
      echo '<dt class="fs2"><b>Propagated Successfully: </b></dt>';
        echo '<dd>';
          foreach( $ok as $url ): echo $url .'<br>'; endforeach;
        echo '</dd>';
      echo '<br><br>';  

      echo '<dt class="warn">Pending Propagation: <b>104.238.188.234</b></dt>';
      echo '<dd class="warn">';
        echo '<table class="bge"><tr class="fwb fs2 tac"><th>site</th><th>IPN</th></tr>';
          foreach( $bad as $url ): 
            echo '<tr>';
              echo $url; 
            echo '</tr>';
          endforeach;
          echo '</table>';  
      echo '</dd>';
    echo '</dl>';
  endif;  
}

Live Demo (with source)

Edit:
Using this function is far better than seeing a representation of the global router results.

The function tests whether the relevant sites have been propagated to my server and reduces the possibilities of where the actual problem arises if the site does not render.

I was surprised at the difference amount of time the sites took to propagate. Some were very quick (only minutes) while others (Godaddy) took hours :frowning:

The Internet has certainly improved since the recommended wait time used to be about 48 hours.

Edit:
Added Output

Output

Propagated Successfully:
johns-jokes.com


Pending Propagation: 
Site            IPN
example.com     93.184.216.34
site-001.com	site-001.com
site-002.com	site-002.com
site-003.com	site-003.com
amazon.com	    176.32.103.205
bing.com	    13.107.21.200
facebook.com	31.13.90.36
google.com	    216.58.213.78
sitepoint.com	54.148.84.95
yahoo.com	    206.190.39.42

1 Like

What are you trying to achieve? The function you presented will certainly work but during the propagation period its results will depend on the location of the server you will run it on and other factors like dns caching. The fact that your function will report that a website of yours has been propagated only means it is seen as propagated on that server only and other people connecting from other locations may still see the old site.

That’s why services like https://whatsmydns.net are supposed to give you a more global and true picture of propagation status. However, from my experience I’ve noticed that https://whatsmydns.net reports dns changes very quickly - usually within a couple of minutes, sometimes up to half an hour, which is misleading because I can see that from some ISP’s I have access to the propagation can take many hours. So now I treat https://whatsmydns.net mostly as a way of checking whether I have configured dns records properly for a domain and accept the fact that I have to wait a lot longer for the propagation to be completed fully.

The propagation progress is best seen though observing server logs both on the old and new server. You can see how gradually the traffic on the old server decreases while on the new server increases. From my observations about 95% of propagation completes within 24 hours and can still see some small traffic to the old server on the following day and usually after 48 hours (sometimes a bit longer) it’s gone completely.

1 Like

Basically I was trying to get a dozen sites working on a new server and to know when to start testing if the site did not render correctly.

One problem encountered was a site failed because a cache directory did not have sufficient permissions. Blank screens are not helpful and checking logs only works if the site has been propagated to the new server.

Using the test routine ensured the new site had propagated and a simple “hello world” index.html proved the site was ok up to that point. Further tests could then be made to test databases, caching, cron jobs, etc.

I appreciate the test function is only for the new site and was quickly able to resolve conflicts within minutes. Once the new site was ok, routing should propagate eventually for the remaining global routers.

Previously changing servers had taken quite some time, even days because I did not know if, when and where the changeover was failing.

Edit:
Forgot to mention about having to re-initialise LetsEncrypt Certbot because each HTTPS Certificate is site specific :frowning:

I see, so if you want to check the propagation on your own computer or server for testing purposes then this function will certainly work.

What I often do when changing servers is insert a small and harmless element on the site on the old server, for example add a dot somewhere on the page or change the colour of menu items, etc., something visible - in this way when I load the page in a browser I can see immediately whether I look at the old or new site.

Also, I’ve noticed that if I want dns to be propagated quickly to my ISP I should avoid visiting the site for some time before the dns change so that my ISP and proxies don’t cache the dns entries. If I’ve just visited the site then I’m sure I’ll have to wait a few hours to see the change. But even then there is a workaround - after about an hour after the dns change I configure my system to use google’s (free) dns servers and then to those dns servers my site visit is usually seen as the first one so the host is resolved anew instead of from a cache and then I have access to the new site much sooner than if I had used default dns configuration in my system.

1 Like

The best is to check the IP of your website. when the IP is changed it will be reflecting. there are numbers of websites that do this for us.

secondly, you can look for your website into the whois database; the nameserver change will be reflecting there.

1 Like

The test page with all my sites had the time displayed to ensure my server was testing if the site was propagated:

echo '<h3>' .date('H:i:s') .'</h3>';

It was quite satisfying to watch the sites flip from the $bad to $ok array :slight_smile:

1 Like

I found the problem with the global web site check sites and the whois database that it was not easy to know when when my new server had propagated.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.