What is DNS and why we need it?
DNS stand for Domain Name System, and it's main job is to translate domain name into IP. Think like every server has an IP and each website host on server so to get access of website we need the IP that look like this 192.168.10.10 (this is just for example) but IPs are not human friendly so we created the domain for that like example.com but the problem is the server don't know the domain it know only the IP to get website location so first we need to translate the normal domain to IP.
DNS Hierarchical Structure.
DNS Hierarchy is in 4 layers, every domain have the hidden dot in the end of domain like www.example.com. and DNS read domain right to left.
Root(.):- The last dot of the domain is the Root.
TLDs(.com):- This is called TLDs(top level domains).
Domain(example):- This is the main domain.
Subdomain(www):- This is the optional and last part of hierarchy.
Role of Recursive Resolver.
Recursive Resolver is responsible of making the sequence of queries to the root, TLDs, and authoritative nameservers to resolves the IP addresses.
Steps in DNS Query.
When we enter a domain name in the browser like google.com our system first add the .(dot) in the last of the domain and then check the IP in cache if that is exists it return from their to browser but if that is not exists that go the the ISP/Public DNS then that check in their cache if exists return from their if didn't go to the root level servers, after that TLDs, then authoritative nameserver to find ip and then get the IP and return back to browser and then the ISP/Public DNS store that ip in cache for next call.
DNS Record Types
A Record:- This record is for store the IPV4
AAAA Record:- This record store the IPv6
CNAME Record:- This record store the subdomain and domain aliasing.
MX Record:- This record store the mail related things.
TXT Record:- This record used to store the arbitrary text data in DNS and some time domain verification related things, and also use to SPF records for email authentication etc.
What is DNS Record?
DNS record is a way to manage multiple things in a domain like the subdomains, IPv4 and IPv6, emails and other things. and each record type have different rules.
What is negative caching, and where it's time come from.
Negative cache is when a domain didn't exists then the DNS caching still cache that NXDOMAIN(does not exist) answer, so repeated lookup for same fake(not exist) domain don't repeat the full search every time.
Why does't a DNS change reflect instantly across the whole internet.
This is the part of the DNS propagation, it mean when we change something in the DNS that don't update instantly bcz all over the world have multiple server to handle DNS and it take time to update so some time we see different ips of same domain in same time.
DNS Privacy Problem
DNS have a problem when we want to open a website for example www.example.com we need it's ip address so we use the DNS resolver but the problem is that DNS request is not encrypted anyone can see that request and our ISPs also, so that problem solve by DoT and DoH.
What is DoT and DoH
DoT stand for DNS Over TLS it added a encryption in the request and it's port is 853 so after using it ISP don't know which website we visiting but ISP still know we using DNS request or not and that problem solve by DoH(DNS Over HTTPS) this send the DNS request like a HTTPS request in port 443 so now ISP didn't know what is the request.
What ports do plain DNS, DoT, and DoH use?
DNS uses 53, DoT uses 853, DoH uses 443
What is HTTP
HTTP stand for Hypertext Transfer Protocol and it's job to talk with server via request, response. and the most important rule is server never talk first, server need a request to response something.
Methods(GET, POST, PUT/PATCH, DELETE)
GET:- This method use for only get data from server, this method never send data to server if you need something use the url something like https://example.com/api/v1/get?userid=123.
POST:- This method use to create something in server, this method use body for send data.
PUT/PATCH:- This method use to update the whole data in db, it replace the whole data but otherhand the PATCH used to update only partial data not whole data.
DELETE:- This method use to Delete something.
Headers
Headers are used to contain extra metadata like Content-Type, Authorization, User-Agent.
What is Head-of-Line blocking in HTTP/1.1, and why does it become a problem when loading multiple files on one page?
Head-of-Line blocking a major problem in the HTTP/1.1 bcz this method only send one request and response in a TCP connection so one request only get one file at a time so we need to send multiple request to get other files that's why we need to open multiple TCP connection that is very inefficient.
What is HTTP/2's "multiplexing" feature, and how does it solve Head-of-Line blocking?
HTTP/2 Solve the Head-of-Line blocking problem via using "multiplexing" it mean you can create multiple request,response in single TCP connection that is call stream.
Even after multiplexing in HTTP/2, what problem does TCP still bring back?
In the HTTP/2 have issues, the major is it uses TCP for stream so if a packet is failed TCP stop other packages that is TCP behavior so this is a major problem that HTTP/2 facing, and that problem solved in HTTP/3 via remove TCP for connection instead use UDP.
Why did HTTP/3 drop TCP in favor of UDP + QUIC?
As you know HTTP/2 have issue to stop if a packet is gone, so HTTP/3 uses UDP with QUIC bcz UDP is not depend on packet lost to stop other that's why the UDP + QUIC fit on this.
What is the Same-Origin Policy, and why do browsers enforce it for security?
Same-Origin Policy mean you can send request on your own origin like you are in website example.com then you only send request on this server example.com bcz if i open a bank website in my tab and i open different website on different tab so that website can send request to my bank server to stole my money that't why browser uses Same-Origin-Policy.
What problem does CORS actually solve, and what's the job of the Access-Control-Allow-Origin header?
The CORS (Cross Origin Resource Sharing) solve the major problem Same-Origin-Policy problem as you know browser can't except other origin response but off-course our server maybe in different origin so how we talk with that, in this scenario the CORS comes in the picture to solve that problem, CORS added a extra key in the response header that is Access-Control-Allow-Origin for browser to identify is server allowed this website or not.
What's the core difference between SSE and WebSocket (in terms of direction)?
SSE stand for Server Sent Event this SSE mean server can send response without client asking but the problem in this model is client can't send the request again, and the WebSocket solve that problem by bidirectional and now server and client send data as they need.
Would you use SSE or WebSocket for a live stock-price ticker, and why? What about a live chat app?
For live stock-price we definitely use the SSE bcz we need server data the client can't send any request, and we use WebSocket for live chat app bcz we need to client and server can send data.
Top comments (0)