What happens on a HTTP request?
September 15, 2007 — HarshitaSo lets look behind the scenes and see what exactly goes on when you type www.yahoo.com in your browser?
- Your browser will first check if it knows the IP address to which yahoo.com domain matches? This domain-IP mapping can be stored in the browser cache when the browser looks it up for the first time.
- If the browser cannot find the domain-IP mapping in it’s cache, it will send a DNS request to the ISPs DNS server. The DNS server will lookup and find the IP mapping for www.yahoo.com. It will then respond with the IP address.
- The browser will get the IP address from DNS server and send the HTTP request for www.yahoo.com to that IP address.
- The server running at that IP address should be hosting the domain yahoo.com.
- The server will look at the incoming request. If the incoming request is a request for an HTML page it will serve it directly back to the client.
- If the request is for a PHP page, then the request will be sent to the PHP engine/module running on the server. The PHP engine/module will execute the PHP code and generate an HTML page will it will be give back to the HTTP server.
- The HTTP server will then send this HTML response back to the client’s browser.
- The browser will then render yahoo.com webpage for the client.
Looking behind the scenes always helps to get a better understanding and complete picture of how things work.