Domain Validation Class Updated
Around three weeks ago, I sent an email to iana.org about their TLD file. (http://data.iana.org/TLD/tlds-alpha-by-domain.txt) This is the file that contains a list of all the valid top level domains (TLDs) on the Internet. Here is a snippet from the email I sent requesting how to best access this file for my domains class:
I would like to access this file directly from my script, but I do not want to over burden your server as I am not certain how much traffic this tool will get. I also want to release it to open source which could increase the traffic exponentially. However, I would like to automate the retrieval of the information so that we ensure we have the most up-to-date data available for validations the TLDs of domains. Do you have any suggestions?
Well I am quite pleased with the response I got back. Kim Davies sent the following response:
It is OK to query this page directly, that is its purpose.
The access pattern you wish to use will depend on how important the file is up to date. Please bear in mind the list of TLDs changes, perhaps at most, once a year at this time. For most applications retrieving a new copy every few months is more than adequate. (Usually when a new TLD is launched, it is piloted with no registrations for several months, so this should not cause a problem.)
The absolute most you should fetch the file is twice a day, as it will never change more often than that. We only make changes to the DNS root zone twice a day.
We would also recommend you use “If-Modified-Since” headers when retrieving the file so that if it has not changed you don’t retrieve the whole file.
So based on her feedback, this is what I did. I added a TLD file status check method to the domains class. This will provide the following functionality:
- checks to see if the file exists
- checks to see how old the file on the server is
- if the file does not exist or is more than 30 days old, it will download a fresh copy
This will provide complete automation for the domains class. As long as the file exists, no matter how old it is, it will allow the domain name to be validated. The validation will NOT be interrupted even if the iana.org domain returns a 404 (not found). Unless of course you don’t have any TLD file at all.
The code can be downloaded from the repository. You can read more information about it’s functionality here: http://code.google.com/p/blogchuck/wiki/DomainsClass
I hope you find it useful. Feel free to comment or send me an email if you have any questions. I will continue to update the code. The key is to keep things as simple as possible while still being useful. Good clean code is easier to use than something just hacked together. I hope I have achieved the prior.
Happy coding!









>
Follow Me (digitally you stalker)