A browser and a web server talk with a set of rules called HTTP. HTTPS is the same set of rules with the data encrypted. This lesson shows how a request and a response work, why HTTPS matters, and what jobs a web browser does.
about 25 min1 simulation1 practice question
Lesson 2 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
A request and a response
Think of a library with a desk. You ask the librarian for a book by its name. The librarian finds it and hands it over, or says that the library does not have it. A browser and a web server work in the same way.
The web server is a computer that stores websites and sends their pages out. The web browser is the program on your device that asks for pages and shows them.
Hypertext transfer protocol (HTTP) is the set of rules for sending web pages between a web server and a browser. Its purpose is to make sure that both sides understand each other.
The browser sends an HTTP request to the web server. The request names the page it wants.
The web server finds the page. It sends back an HTTP response. The response holds the page, written in HTML, or a message that the page was not found.
A web page often has other files too: pictures, styles and programs. The browser sends a separate request for each file.
A web browser on the left and a web server on the right, with four arrows between them. From the top: an arrow from the browser to the server labelled HTTP request: GET /news.html; an arrow back labelled HTTP response: the page in HTML; then, in red, an HTTPS request and an HTTPS response, each labelled encrypted with SSL. A note under them says that HTTPS is the same request and response, but encrypted.
Why one page can need many requests
Each file needs its own request and response, and each one takes time to go there and back. Suppose a page has 12 files and each request and response takes 50ms (milliseconds). One at a time, the page takes 12×50=600ms. A browser can send several requests at the same time, so it needs fewer rounds.
HTTPS: the secure version
HTTP sends its data as plain text. Anyone who intercepts the data on its way can read it, and that may include a password or a card number. You meet this threat, data interception, in the course on cyber security.
Hypertext transfer protocol secure (HTTPS) is HTTP with encryption added. It uses a security protocol called secure socket layer (SSL). Before any page is sent, the browser and the web server agree how to encrypt the data. Then every request and every response travels encrypted. Data that is intercepted cannot be understood without the key.
The URL starts with https instead of http.
Most browsers show a small padlock in the address bar.
The web server proves who it is with a digital certificate, so the browser knows it is talking to the real website.
You saw symmetric and asymmetric encryption in the chapter on data transmission. HTTPS uses them. The newer form of SSL is called TLS, but the idea is the same.
What a web browser does
The main purpose of a web browser is to render HTML and display web pages. To render means to read the HTML code and turn it into the page you see: the headings, the text, the pictures and the links.
A browser has other functions too.
It stores bookmarks and favourites, so you can go back to a page quickly.
It records your history, the list of pages you have visited.
It allows multiple tabs, so several pages are open at the same time.
It stores cookies, small files that websites ask it to keep. The next lesson explains them.
It provides navigation tools: back, forward, reload and home.
It provides an address bar, where you type a URL or see the address of the page.
Practise with new numbers
Try it in Python
The program plays both parts. A dictionary holds the pages of a small web server. The function web_server gets a request such as GET /news.html and returns a response. GET is the word HTTP uses to ask for a page. The status 200 OK means the page was found, and 404 Not Found means it was not.
Common mistakes
Saying HTTPS makes a website safe in every way. HTTPS encrypts the data on its way. A fake website can also use HTTPS, so you still check the URL.
Thinking the browser stores the website. The web server stores it. The browser asks for each page and shows it.
Forgetting that the response can be an error. If the page is not there, the server says so.
Mixing up rendering and storing. Rendering is turning HTML into the page on the screen.
Remember these
HTTP is the set of rules for sending web pages between a web server and a browser, by request and response.
HTTPS is HTTP with the data encrypted, using the SSL security protocol.
The main purpose of a browser is to render HTML and display web pages. It also stores bookmarks, history and cookies, allows tabs and gives navigation tools and an address bar.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
What does a web server send back when it gets an HTTP request for a page that it holds?
Ali logs in to a website whose URL begins with http://. Why is this a risk?
A page has 9 files. Each request and response takes 40ms. The browser sends 3 requests at the same time. How long does the page take to load?
Name two functions of a web browser apart from showing pages.
What is the main purpose of a web browser?
Enroll free in The Internet, the Web and How Pages Reach You
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.