# Http & Https

## Introduction

HTTP is a set of rules for communication between a client (like a web browser) and a server. When a website is visited, an HTTP request is sent by the browser to the server, which responds with data in plaintext (unencrypted). HTTPS is a more secure version of HTTP. With HTTPS, an encrypted connection is first established by the browser and server before data is exchanged, ensuring the data remains secure and private.

![What is the difference between HTTP and HTTPS? (Detailed Guide)](https://serverguy.com/wp-content/uploads/2019/09/download-8.png align="left")

## How HTTP protocol work?

The HTTP protocol is a set of rules that allows web browsers and servers to communicate with each other. When a website is to be viewed, an HTTP GET request is sent by the browser to the server. If data is to be submitted, like a form, an HTTP PUT request is sent by the browser. The server then responds with a status code like 200 (OK), 400 (Bad request), or 404 (Not found), along with the requested data. This request-response communication happens behind the scenes, allowing the World Wide Web to function consistently.

**HTTP Request:**

```bash
GET / HTTP/1.1
Host: www.example.com
```

**HTTP Response**:

```bash
HTTP/1.1 200 OK
Date: Fri, 23 Aug 2019 22:38:34 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 138
Last-Modified: Tue, 08 Jan 2019 23:11:55 GMT
Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)
Accept-Ranges: bytes
Connection: close
<HTML Body>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1737173531157/d03d00b9-e984-4f61-9c6e-8d8dd298e69c.png align="center")

## How HTTPS protocol work?

The HTTPS protocol is used to establish a secure, encrypted connection between the browser and server before data is transmitted. Unlike HTTP, which sends data in plaintext that can be intercepted, HTTPS combines HTTP requests and responses with SSL/TLS encryption technology. To enable HTTPS, an SSL/TLS certificate must be obtained by websites from a trusted certificate authority. The certificate is shared with the browser to establish an encrypted connection and allow secure data exchange between the browser and server.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1737173497010/c7115437-cc1c-4677-a674-86cf741df22a.png align="center")

## **HTTPS setup more expensive than HTTP?**

Setting up HTTPS is no longer more expensive than HTTP. In the past, an annual fee was required to obtain and maintain an SSL/TLS certificate for HTTPS. However, nowadays, many sources offer free SSL certificates, such as AWS Certificate Manager. So the cost of setting up HTTPS has been significantly reduced. Encryption is used, so when data is sent or communication occurs, the encryption works, which can increase the server bill. Therefore, it is not used for server-to-server communication.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1737175041769/70d8612d-72d3-467f-a42d-8ae26005025b.png align="center")

## **Differences between HTTP vs. HTTPS**

<table><tbody><tr><td colspan="1" rowspan="1"><p>HTTP is the standard protocol for transferring data over the internet.</p></td><td colspan="1" rowspan="1"><p>while HTTPS adds an extra layer of security by encrypting the data using SSL/TLS certificates.</p></td></tr><tr><td colspan="1" rowspan="1"><p>HTTP uses port 80 and is suitable for older, text-based websites.</p></td><td colspan="1" rowspan="1"><p>Port 443 is used by HTTPS and is recommended for all modern websites as security, authority, trust, and search engine rankings are improved.</p></td></tr><tr><td colspan="1" rowspan="1"><p>TCP/IP is used by HTTP/1 and HTTP/2, while the newer QUIC protocol is used by HTTP/3.</p></td><td colspan="1" rowspan="1"><p>HTTPS combines HTTP/2 with SSL/TLS encryption for secure data transfer.</p></td></tr><tr><td colspan="1" rowspan="1"><p>HTTP is not considered more expensive.</p></td><td colspan="1" rowspan="1"><p>HTTPS is considered more expensive.</p></td></tr></tbody></table>

## Conclusion

* **HTTP** transmits data in plain text, making it insecure for sensitive information. It is increasingly outdated and less trusted for modern web applications.
    
* **HTTPS** encrypts data to protect user information from being intercepted or altered. It is essential for maintaining security, trust, and compliance with today's web standards.
    
* **Recommendation**: Always use **HTTPS** for websites to ensure secure communication, user trust, and better SEO rankings.
