How HTTP Works

Updated on

In the last tutorial on DNS we looked at how the browser finds out the IP address of the Web server for a given domain name.

Once the browser knows the location (IP address) of the computer that serves content for the given domain name, it can use another protocol to fetch the document or resource that the user requested.

The name of that other protocol is HTTP, or HyperText Transfer Protocol.

First, the browser sends a request with instructions about what resource it wants to fetch. Then the server looks at that request and sends back a response.

HTTP requests and responses

“Protocol” just means that there is an established technique for sending files over the Web, and the technique is called HTTP. As long as your program follows the rules of HTTP protocol, it can communicate with other computers that use the same protocol. We’ll go into more details of HTTP in later chapters.

Web Clients and Servers

A client is a program that makes requests to a server. A Web browser is an example of a Web client.

A server is a program that responds to requests. Some Web servers have well-known names like Apache and NGINX.

There can be many clients and servers running on a computer at the same time.

The Web server configuration can be more complex than just a single server, but for practical purposes, when you connect to a URL, you are connecting to someone’s computer somewhere.

That user-facing server is probably connected to additional servers, for example there may be an application server (running PHP or Node.js) and a database server, like MariaDB or PostgreSQL.

I’m just sketching out an overview, so the details aren’t important yet. We’ll return to it later.

The important thing to remember here is that your browser is hitting a server, but there might be multiple servers in various kinds of configurations.

Clients and servers on the Web

The Server Response

We’ll cover responses in detail later, but typically what happens is that the initial request is for the URL of a webpage. That webpage returns HTML code. The browser reads the HTML code and starts rendering the page, making additional requests for other files that are referenced in the HTML code, like CSS stylesheets, JavaScript files, images, and videos.

Takeaways

Things that you should remember from this section:

Return to the main tutorial page.

Feedback and Comments

What did you think about this page? Do you have any questions, or is there anything that could be improved? You can leave a comment after clicking on an icon below.