web_basics
web_basics
HTTP
Hypertext Transfer Protocol
Protocol → Set of rules [ Protocol used to transfer Hypertext ]
Hypertext → Text docs → Hyperlink [ These hyperlinks connect one document to
other documents, resources, or information. ]
Inspect element
Page Source
Stateless Protocol
Session
Example: If you log in to a website, your session starts. The server stores your
login details so that as long as you stay on the website, you don't have to log in
again. When you log out from the website, the session ends.
1. Cookies: Cookies are small files that the server stores in the user's browser.
These cookies can store the user's state (like login status, preferences) or
session ID. When the user returns to the website, the server identifies their
session using the cookies.
2. Session ID: The server generates a unique session ID when the user logs in or
starts a session. This session ID is sent with each user request to the server. It
helps the server know which request is part of which session.
3. Session Data: The server also stores temporary data like the user's login
status, shopping cart, or preferences. This data is stored as long as the
session remains active.
Cookie
Cookies are small files stored in web browsers that are sent by the server to the
user's browser.
State Maintenance
Personalized Experience
Types of cookies
1. Session Cookies: These are temporary cookies that are automatically deleted
when the browser is closed. They are used to store session data.
Example: If you are on an online shopping website and fill your shopping cart, the
server stores the cart information using cookies. When you visit the website again
the next day, your cart remains the same as it was last time.
HTTP Headers
When the browser (client) sends a request to the server, various types of
information are sent along with that request, which is in the form of headers.
Headers contain metadata that provides extra information about the request or
response, such as content type, authentication, cookies, etc.
Client Information
Browser Info
Date Time
Cookie to store
Response code
HTTP response codes are status codes sent by the server to inform the client
about the result of the request.
HTTP/2
http/1.1 is a fallback & is still used
HTTP/2 is the second major version of the Hypertext Transfer Protocol (HTTP),
designed to improve the performance and efficiency of web communication.
Multiplexing No Yes
User Agent
TCP
1. Connection-Oriented Protocol
When you send data (like a file or message), TCP divides that data into smaller
packets. These packets are of a particular size, and each packet has its own
address and sequence number.
Reliability is the most important feature of TCP. When data packets are sent,
TCP ensures that all packets reach the receiver in the correct order and in
complete form. If any packet is lost or damaged, TCP requests to resend it.
4. Sequencing:
TCP assigns a sequence number to each packet. When the receiver receives
the packets, it arranges the data in the correct order based on these numbers
to ensure that no data is missed.
5. Acknowledgment (ACKs):
If the receiver doesn't receive the packet or something goes wrong, it sends a
negative acknowledgment (NAK) to the sender, and the sender retransmits
6. Flow Control:
TCP uses a flow control mechanism. This comes into play when the sender is
sending data too quickly, and the receiver needs time to process that data.
This mechanism informs the sender when to stop sending data, preventing the
receiver from being overloaded.
7. Congestion Control:
Congestion → traffic
TCP uses congestion control when there is congestion on the network (e.g.,
when many devices are sending data simultaneously). It detects congestion
and slows down the data transmission to ensure that the network's resources
are properly managed.
8. Three-Way Handshake:
9. Termination:
TCP includes a checksum in its packets, which ensures that the packets are
transferred without any errors. If a packet is corrupted, the receiver will discard it
and request a resend.
IP
Internet Protocol
It is a network protocol that defines the method of transferring data between
devices.
URL
DNS
Domain Name System
Points URL to IP
It is a system that converts human-readable domain names into machine-readable
IP addresses on the internet.
Header
Payload
Cache
Store [temp] the Data