Since past 1 week or so I am trying to make a small tiny light weight web server of my own, and for the same I have been referring to dozens of papers, websites, people and what not. I still haven’t finished making one, I am still toggling between Java and Python, since both seems to satisfy my needs and unfortunately I am master in none. While I was digging deep into the theory of how can I make a web server, I cleared many other concepts of mine, which finally leads to this post.
“What happens before you finally viewed this page/post of mine ?” – Many of you might know behind the scene stories and many like me might have a vague idea. But for the good of all those who don’t know and for people like me who needs a reference, I thought of better penning it down.
Lets see what possibly is going in the background:
- Suppose you type in http://www.yahoo.com in your web browser or clicked this link on some other page.
- Your browser see’s the above URL, and identifies it as a HTTP protocol.
- Then it breaks the URL into Protocol, Domain Name, File Name (in above case no file name is specified)
- Browser contacts its default DNS (Domain Name Server), which helps it with an IP Address. DNS is a huge distributed database which contains mapping of URL’s to IP Address. Your browser’s default DNS might or might not have the required mapping of URL to IPAddress.
- If it don’t have the IPAddress corresponding to http://www.yahoo.com , it will try to contact other root name servers for the required IPAddress.
- If it already have the IPAddress corresponding to http://www.yahoo.com (which is possible if a similar request has already been made recently) it will provide the required IPAddress to your browser.
And finally your browser then connects to the IPAddress it received and servers you the page returned back by Yahoo!. If you are still not clear about the process, following practical example might help you.
- I thought of starting a website and decided to name it as http://gtalkbots.com
- Firstly, I needed to register domain name with a registrant. For e.g. In my case I blocked the domain name gtalkbots.com with godaddy.com.
- Secondly, I needed to have a machine i.e. a place where I can have all my HTML, PHP files. So I bought a VPS (Virtual Private Server)
- Thirdly, I had to link the above two i.e. when someone types in http://gtalkbots.com in his browser, it should come to my VPS where I have my HTML files.
- For linking the domain name and my VPS, I simply make an ARecord entry at godaddy, telling it the IPAddress of my VPS. In turn when you type in http://gtalkbots.com in your browser, GoDaddy redirects you to my VPS. (Google for ARecord and CNAME for more details)
- Last 4 entries in the image above are for linking my gtalkbots.com domain with my google apps account, so that I can send and receive my gtalkbots.com email on google apps.
There is a lot more to it, however the info above is more than sufficient to understand the basics of
“What happens before you finally viewed this page/post of mine ?”