Update DNS for domain name in AJAX request

We have DNS failover setup, with a TTL of 180 seconds. When a server fails, it updates the IP address on the A Host records to that of the working server. Currently, our website refreshes using AJAX requests on an interval. When one of the servers fails, the DNS is updated and failed over, so if you ping the domain it has the proper IP. For some reason though, inside the browser and long after the TTL has expired, the AJAX request still retains the old IP address assigned to the domain name (note the page cannot be reloaded in the browser). I am aware as of reading other questions that you cannot force a flush of the DNS cache on the client. My question is, do any of you know another way or trick to accomplish this using javascript or AJAX? Thanks.


Use two (or more) subdomains. eg. data1.example.com and data2.example.com that correspond to the physical servers.

However, for cross domain to work, you need to set document.domain which allows the communication between domains:

document.domain = "example.com";

Then, you need your script to fail over between the different servers manually. It is the only way that I know of and has been successful in many installs.

Leave a Reply

Your email address will not be published. Required fields are marked *