0% found this document useful (0 votes)
2 views6 pages

DNS and TLS in Web Communication

DNS translates domain names into IP addresses, enabling the location of servers for web communication, while TLS secures the data exchanged between clients and servers through encryption, authentication, and data integrity. The React component life cycle consists of three phases: mounting, updating, and unmounting, which manage the component's creation, re-rendering, and destruction. This life cycle is crucial for single-page applications to optimize memory management and performance by ensuring efficient handling of side effects and preventing memory leaks.

Uploaded by

yashmharav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

DNS and TLS in Web Communication

DNS translates domain names into IP addresses, enabling the location of servers for web communication, while TLS secures the data exchanged between clients and servers through encryption, authentication, and data integrity. The React component life cycle consists of three phases: mounting, updating, and unmounting, which manage the component's creation, re-rendering, and destruction. This life cycle is crucial for single-page applications to optimize memory management and performance by ensuring efficient handling of side effects and preventing memory leaks.

Uploaded by

yashmharav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Web Computing

Explain the role of DNS and TLS in web communication.


Ans:- 1. Role of DNS (Domain Name System)
The role of DNS is to act as the Internet's phonebook, translating
human-readable domain names into machine-readable IP addresses.
 Primary Function (1 Mark): Name Resolution. It locates the
specific server hosting the website, which is the necessary first
step before a connection can be made.
 Mechanism (1 Mark): It uses a global hierarchy of servers to find
the correct IP address and directs the client (browser) to the
target server.

🔒 2. Role of TLS (Transport Layer Security)


The role of TLS (used in HTTPS) is to secure the communication channel
between the client and the server.
 Encryption (1 Mark): It uses cryptography to encrypt all data
exchanged (passwords, payment details), ensuring that third
parties cannot read the information.
 Authentication (1 Mark): The TLS Handshake verifies the server's
identity using a digital certificate, confirming that the client is
connecting to the legitimate website and not a malicious
impostor.
 Data Integrity (1 Mark): It ensures that the transmitted data has
not been tampered with or altered during transit.
Summary: DNS finds the server; TLS secures the communication to and
from that server.
Difference between ES5 and ES6
Discuss the life cycle of a React component and its significance in
single-page application (Give answer)
Ans:-
🔁 The Three Component Life Cycle Phases
The React life cycle is divided into three main phases, which are
managed in Functional Components primarily through the useState (for
state) and useEffect (for side effects/life cycle) Hooks.
1. Mounting (Initialization/Birth)
This phase is the component's creation and insertion into the DOM. It
runs only once.
 Action: Initial rendering of the component's UI.
 Key Hook Use (2 Marks):
o Data Fetching: Use useEffect(() => { /* fetch data */ }, []). The
empty dependency array ([]) tells React to run the effect only
once after the initial render.
o Setup: Initializing subscriptions, setting up event listeners, or
integrating with third-party libraries (e.g., a map library).
2. 🔄 Updating (Re-rendering/Growth)
This phase occurs whenever the component's state or props change,
resulting in a re-render. This is the most frequent phase.
 Action: React performs its diffing algorithm on the Virtual DOM
and updates the actual DOM to reflect the new state/props.
 Key Hook Use (1 Mark):
o Side Effects: Use useEffect(() => { /* run effect */ },
[dependency]). The effect runs after every render where the
value of the dependency (e.g., a prop like userId or state like
count) has changed.
3. Unmounting (Clean Up/Death)
This phase occurs when the component is removed from the DOM. It
runs only once.
 Action: The component is destroyed and removed from the UI
tree.
 Key Hook Use (1 Mark):
o Cleanup: The return function inside useEffect handles
cleanup: useEffect(() => { /* setup code */ return () => { /*
cleanup code */ }; }, []). This return function is executed just
before the component is destroyed.

🎯 Significance in SPAs (1 Mark)


The life cycle is vital for SPAs, which are long-running applications that
do not perform full page reloads:
 Memory Management: The unmounting cleanup phase is
essential for preventing memory leaks. It ensures that timers,
subscriptions, and event listeners created in the mounting phase
are properly cleared when the component is destroyed.
 Performance: By utilizing the useEffect dependency array,
developers ensure side effects (like API calls) run only when
necessary (during mounting or when specific dependencies
change), preventing excessive network traffic and unnecessary re-
renders that would degrade the SPA's responsiveness.

You might also like