Explain the lifecycle of an internet request

Explain the lifecycle of an internet request

Lifecycle of an internet request

Internet is a very complex and distributed archiecture. Lifecycle of a typical http request is very complex depending how you look at it but as a front end engineer I can explain it in following steps.

User enters a url in browser

User actions often trigger web requests. Typing a URL (Uniform Resource Locator) into your browser's address bar is one way to do this. The URL includes a domain name (which identifies the website) and a path (which specifies the content you want). Today, most websites use HTTPS (Hypertext Transfer Protocol Secure) as their communication protocol. HTTPS provides a secure, encrypted connection, protecting your data during transmission. While HTTP (Hypertext Transfer Protocol) is still possible, it lacks encryption, making data transfers potentially vulnerable to interception.

DNS resolution.

When user hits enter in the browser, the browsers first looks at the hostname and tries to resolve the domain name to an IP address. This is done by quering a DNS server.

A DNS server translates domain name and provides an IP addresss to the browser.

Establishing Connection

Browser than connects to the IP address on PORT 80 unless another port was specified. For HTTPS it is port 443.

URL Path

Browser than presents the rest of the path to the connection.

For example this could be example.com/somepath

Depending on the server technology, the server knows how to interprete the path. In case of nodejs based servers, the path would map to some handler. This hander returns some string back on the connection.

Browser receiving the connection response

The string sent back by server on the http connection is called HTTP response. Browser can render it in the screen.

Connection closing

Browser closes the connection after the reponse is received. HTTP is called a stateless protocol because we alway exchange requests and responses on one connection and then close the connection.

There are concepts like web sockets but that is not common.

Conclusion

Once browser has received the response. Browser decides to parse it and render it. This code could be html, javascript, css etc.