<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: DeveloperJoe</title>
    <description>The latest articles on DEV Community by DeveloperJoe (@developerjoe).</description>
    <link>https://dev.to/developerjoe</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1461575%2Ff465e4e4-ced7-4465-8aef-518268b12dd9.png</url>
      <title>DEV Community: DeveloperJoe</title>
      <link>https://dev.to/developerjoe</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/developerjoe"/>
    <language>en</language>
    <item>
      <title>Interview Question: Explain the lifecycle of HTTP request</title>
      <dc:creator>DeveloperJoe</dc:creator>
      <pubDate>Wed, 01 May 2024 14:05:50 +0000</pubDate>
      <link>https://dev.to/developerjoe/interview-question-explain-the-lifecycle-of-http-request-1pa5</link>
      <guid>https://dev.to/developerjoe/interview-question-explain-the-lifecycle-of-http-request-1pa5</guid>
      <description>&lt;p&gt;It is one of the most common question these days for interviews. However I think this question has very little utility. A person can be excellent front end engineer without ever having to know how DNS works. &lt;/p&gt;

&lt;p&gt;But those who are looking for answers I have written this answer by &lt;a href="https://www.frontendeng.dev/"&gt;referring to this excellent resource for frontend engineering&lt;/a&gt;. &lt;/p&gt;

&lt;h2&gt;
  
  
  Request Initiation
&lt;/h2&gt;

&lt;p&gt;Request is often initiated by some user action. Typing url in browser, clicking on a link etc. The browser obtains the link and decides to fetch it for you by first looking at the TLD of the hostname. For example &lt;a href="http://www.mydomain.com/path"&gt;www.mydomain.com/path&lt;/a&gt; would make the browser first look at mydomain.com &lt;/p&gt;

&lt;h2&gt;
  
  
  DNS Resolution
&lt;/h2&gt;

&lt;p&gt;Browser queries the DNS service in OS to convert mydomain.com to an ip address. Once it is resolved it looks up the &lt;a href="http://www.mydomain.com"&gt;www.mydomain.com&lt;/a&gt; which is called the subdomain. &lt;/p&gt;

&lt;h2&gt;
  
  
  TCP connection
&lt;/h2&gt;

&lt;p&gt;Browser that tries to open a connection on port 80 on the resolved IP address. These days it is going to be port 443 because of SSL. &lt;/p&gt;

&lt;p&gt;This process involves TCP/TLS handshake. Once the connection is established browser looks at the "path" portion in the URL. &lt;/p&gt;

&lt;h2&gt;
  
  
  PATH
&lt;/h2&gt;

&lt;p&gt;Browser then presents the rest of the path to the server with which it has oppened the connection. Depending on the request type (GET/POST/DELETE) etc. it might also provide additional data to server. &lt;/p&gt;

&lt;p&gt;The server will handle this information based on what kind of technology and architecture it has. &lt;/p&gt;

&lt;h2&gt;
  
  
  The server takes in all the input and generates an outpu
&lt;/h2&gt;

&lt;p&gt;This output is passed back to the server. &lt;/p&gt;

&lt;p&gt;Both client and server close the TCP connection. &lt;/p&gt;

&lt;h2&gt;
  
  
  The browser loads everything on the screen.
&lt;/h2&gt;

&lt;p&gt;The browser then looks at the content-Type of the response and renders it in the viewport. &lt;/p&gt;

&lt;p&gt;There are plenty of steps that go into this rendering process but we will leave that out. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This is what an interviewer is looking for in such questions whether you have good basic understanding of most of these steps or not. &lt;/p&gt;

&lt;p&gt;[1] &lt;a href="https://www.frontendeng.dev/blog/46-explain-lifecycle-of-internet-request"&gt;https://www.frontendeng.dev/blog/46-explain-lifecycle-of-internet-request&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
    </item>
  </channel>
</rss>
