How HTTP works
- Request: the browser asks for a resource with a method such as GET (fetch a page) or POST (send form data).
- Response: the server replies with a status code, such as 200 (OK), 301 (moved) or 404 (not found), plus headers and the content.
- Headers: extra information, such as the content type, caching rules and cookies.
HTTP versions
HTTP/1.1 dates from the 1990s. HTTP/2 and HTTP/3 load pages faster by sending many files over one connection, and HTTP/3 runs over the QUIC protocol. In browsers, HTTP/2 and HTTP/3 are only used over encrypted connections.
HTTP vs HTTPS
Plain HTTP sends data unencrypted, so anyone on the network can read or change it. HTTPS adds TLS encryption. Browsers mark HTTP pages as “Not secure” and Google prefers HTTPS, so every website should redirect HTTP to HTTPS.
HTTP request example
You open https://www.example.com/shoes/. The browser sends a GET request for /shoes/ and the server replies with status 200 and the HTML. The browser then reads the HTML and sends further requests for the style sheet, images and scripts. Each is a request and a response. If the shoe page was moved, the first reply might be 301 with the new address.
HTTP things worth checking on your site
- Every important page returns 200.
- Moved pages use 301 redirects with no chains.
- Your server supports HTTP/2 or HTTP/3 and uses HTTPS.
- Caching headers are set for images and scripts.
- Response times are short, especially for the first byte.
HTTP mistakes
- Serving the same page on both HTTP and HTTPS without redirecting.
- Returning 200 for pages that do not exist, known as soft 404s.
- Using a temporary redirect for a permanent move.
HTTP FAQs
What is the difference between HTTP and HTTPS?
HTTPS is HTTP with encryption. See HTTPS and SSL.
What are status codes?
See HTTP status codes, 301 redirects and 400 errors.