title: How does a web browser request and receive a web page?
body: <p>Got asked this interesting interview question today.</p>
  
  <blockquote>
    <p>Explain in detail the process by which a client machine requests a file (say file.php) from the server, and then receives that desired file along with its necessary JS/CSS/images/video files and they appear on the client's browser screen.</p>
  </blockquote>
  
  <p>Here is what I do know and what I did say:</p>
  
  <blockquote>
    <p>So a request is sent, then the server sees that the file.php file is being requested, and because it has a .php extension, it first uses the PHP engine to parse any PHP code inside the file, and then once it is done, it outputs back to the client machine the resulting file.php file (as a response). The browser then takes that response and parses the HTML and necessary JS and CSS code, then displays it to the browser.</p>
  </blockquote>
  
  <p>My answer is pretty basic and not as detailed as it should be. I thought about my response and came up with new questions:</p>
  
  <ol>
  <li><p>What, literally, is a "request"? Is it basically just the textual header file that gets sent to the server?</p></li>
  <li><p>What about a "response"? Is the response itself the parsed file.php file that gets sent back to the client machine?</p></li>
  <li><p>What if the file.php file contains a reference to a script.js file and a style.css file? At which stage do those files get served back to the client machine? Do they come in as separate headers or what?</p></li>
  <li><p>Above in my answer, I'm not sure if I was correct when I said "...because it has a .php extension, it first uses the PHP engine to parse any PHP code inside the file." Is that really the reason why the server parses the code inside the file, or does the server scan ALL kinds of files by default to check for any PHP code they might contain?</p></li>
  </ol>