Sr. PHP Programmer Question:
Download Questions PDF

What exactly is an HTTP request?

Answer:

The question asks for two major things from a URL - the total number of HTTP requests and the total download size for all requests. The download size is easy enough to understand, but you may be confused by what exactly is meant by an HTTP request. HTTP is the protocol used to communicate on the web. When you visit a webpage, your browser will make an HTTP request to the server that hosts that webpage, and the server on which the webpage is hosted will respond with an HTTP response.

But, what is important to understand here, is that your browser will probably have to make multiple HTTP requests in order to retrieve a single HTML page at a given URL, because that webpage will probably have some CSS files to go along with it, some Javascript files, and probably some images as well. Each one of those resources is a separate HTTP request - 2 image files, 2 Javascript files, and 2 CSS files means 6 separate HTTP requests. In HTTP, only one resource can be requested at a time - so we can not have 1 request for 6 different resources, instead we must have 6 requests for those 6 different resources.

So, for the purpose of this interview question, we have to find out the number of HTTP requests that will be made for a given URL - hopefully what that means is now clear to you. We'll go more in depth on this later - and show some actual code - as we cover some other things as well.

Download Senior PHP Programmer Interview Questions And Answers PDF

Previous QuestionNext Question
What are some PHP Design patterns you have worked with?What are the main error types in PHP and how do they differ?