<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Ajay Panigrahi]]></title><description><![CDATA[Ajay Panigrahi]]></description><link>https://ajaypanigrahi.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 20:56:06 GMT</lastBuildDate><atom:link href="https://ajaypanigrahi.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Express Middleware Explained: How app.use(), next(), Routes & Error Handling Work]]></title><description><![CDATA[Watch the YouTube video
Prefer visuals and a step-by-step explanation? Watch the video above.
Prefer reading? This article covers the same idea from scratch in a few minutes.
So we'll build it from th]]></description><link>https://ajaypanigrahi.hashnode.dev/express-middleware-explained-how-app-use-next-routes-error-handling-work</link><guid isPermaLink="true">https://ajaypanigrahi.hashnode.dev/express-middleware-explained-how-app-use-next-routes-error-handling-work</guid><dc:creator><![CDATA[Ajay B Panigrahi]]></dc:creator><pubDate>Fri, 04 Sep 2026 06:11:40 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/67838ce2909c53cdbca682a8/5b484e49-912a-4418-ae86-799f982375f2.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a href="https://youtu.be/DMCUacG1c5I">Watch the YouTube video</a></p>
<p>Prefer visuals and a step-by-step explanation? Watch the video above.</p>
<p>Prefer reading? This article covers the same idea from scratch in a few minutes.</p>
<p>So we'll build it from the ground up:</p>
<pre><code class="language-text">Express
  ↓
Routes &amp; HTTP methods
  ↓
Callback functions
  ↓
Route handlers
  ↓
Chaining functions
  ↓
next()
  ↓
Middleware
  ↓
Multiple middleware
  ↓
Error handling
  ↓
Types of middleware
</code></pre>
<p>A lot of tutorials make middleware sound more complicated than it really is.</p>
<p>We'll keep it simple and understand what's actually happening.</p>
<h2>Start with a simple Express app</h2>
<pre><code class="language-js">const express = require("express");

const app = express();

app.get("/", (req, res) =&gt; {
  res.send("Hello World");
});

app.listen(3000);
</code></pre>
<p>The basic flow is:</p>
<pre><code class="language-text">Client
  ↓
Request
  ↓
Express
  ↓
Route Handler
  ↓
Response
</code></pre>
<p>The function passed to <code>app.get()</code> is called the <strong>route handler</strong>.</p>
<h2>What is a callback?</h2>
<p>Look at this:</p>
<pre><code class="language-js">app.get("/users", (req, res) =&gt; {
  res.send("Users");
});
</code></pre>
<p>We are passing a function to another function.</p>
<p>Express receives that function and calls it later when a matching request arrives.</p>
<p>That function is a <strong>callback</strong>.</p>
<p>In this example, the callback is also the route handler.</p>
<h2>Express has different HTTP methods</h2>
<p>You will commonly see:</p>
<pre><code class="language-js">app.get("/users", handler);
app.post("/users", handler);
app.put("/users", handler);
app.patch("/users", handler);
app.delete("/users", handler);
</code></pre>
<p>The method tells Express what kind of request should match.</p>
<p>There is also <code>app.use()</code> and <code>app.all()</code>.</p>
<h2>What is <code>app.use()</code>?</h2>
<pre><code class="language-js">app.use(handler);
</code></pre>
<p><code>app.use()</code> is not tied to one specific HTTP method.</p>
<p>You can also give it a path:</p>
<pre><code class="language-js">app.use("/api", handler);
</code></pre>
<p>This can apply to requests such as:</p>
<pre><code class="language-text">GET    /api/users
POST   /api/users
GET    /api/products
DELETE /api/products/123
</code></pre>
<p>The path is optional for <code>app.use()</code>:</p>
<pre><code class="language-js">app.use((req, res, next) =&gt; {
  console.log("Request received");
  next();
});
</code></pre>
<p>Without a path, it can run for requests that reach this point in the application.</p>
<p>At this stage, we are only looking at the syntax and matching behavior. We'll call these functions <strong>middleware</strong> later.</p>
<h2>What is <code>app.all()</code>?</h2>
<p>You might not even know that <code>app.all()</code> exists.</p>
<pre><code class="language-js">app.all("/users", handler);
</code></pre>
<p><code>app.all()</code> matches the <code>/users</code> route for <strong>all HTTP methods</strong>.</p>
<p>For example:</p>
<pre><code class="language-text">GET    /users
POST   /users
PUT    /users
PATCH  /users
DELETE /users
</code></pre>
<h2><code>app.use()</code> vs <code>app.all()</code></h2>
<p>They can both work regardless of the HTTP method, but their path matching is different.</p>
<pre><code class="language-text">app.all("/users")
→ route-path matching

app.use("/users")
→ prefix / mount-path matching
</code></pre>
<p>For example:</p>
<pre><code class="language-text">app.all("/users")

✅ GET    /users
✅ POST   /users
✅ DELETE /users

❌ GET    /users/123
</code></pre>
<p>But:</p>
<pre><code class="language-text">app.use("/users")

✅ GET    /users
✅ GET    /users/123
✅ POST   /users/123
✅ DELETE /users/123
</code></pre>
<p>So the simple mental model is:</p>
<pre><code class="language-text">app.all()
→ all methods for one route

app.use()
→ all methods for a path prefix
</code></pre>
<h2>What about the route path and callback?</h2>
<p>For <code>app.get()</code>, <code>app.post()</code>, <code>app.put()</code>, <code>app.patch()</code>, <code>app.delete()</code>, and <code>app.all()</code>, the route path is part of the route definition:</p>
<pre><code class="language-js">app.get("/users", handler);
app.post("/users", handler);
app.all("/users", handler);
</code></pre>
<p>You can pass the callback directly:</p>
<pre><code class="language-js">app.get("/users", (req, res) =&gt; {
  res.send("Users");
});
</code></pre>
<p>You don't have to create a named function first.</p>
<p>With <code>app.use()</code>, the path can be omitted:</p>
<pre><code class="language-js">app.use((req, res, next) =&gt; {
  next();
});
</code></pre>
<p>So:</p>
<pre><code class="language-text">app.get("/users", handler)
→ GET /users

app.all("/users", handler)
→ all methods for /users

app.use("/users", handler)
→ all methods for /users and matching sub-paths

app.use(handler)
→ no path restriction
</code></pre>
<h2>Route paths can use more than simple strings</h2>
<p>A route path does not always have to be a plain string.</p>
<p>Express also supports <strong>regular expressions</strong> as route paths:</p>
<pre><code class="language-js">app.get(/\/users\/\d+/, (req, res) =&gt; {
  res.send("User route");
});
</code></pre>
<p>This can match paths such as:</p>
<pre><code class="language-text">/users/123
/users/456
</code></pre>
<p>The idea is still the same:</p>
<pre><code class="language-text">Request path
    ↓
Path pattern
    ↓
Match?
    ↓
Run handler
</code></pre>
<p>Express 5 still supports regular expressions as paths.</p>
<p>What changed in Express 5 is the older string-pattern syntax. Some special pattern characters that worked inside string paths in older Express versions no longer work the same way.</p>
<p>When you need a real regular expression, use an explicit <code>RegExp</code> such as:</p>
<pre><code class="language-js">/\/users\/\d+/
</code></pre>
<p>You don't need to remember this unless you actually need complex route matching.</p>
<h2>A route can have multiple functions</h2>
<p>A route can receive more than one function:</p>
<pre><code class="language-js">app.get(
  "/users",
  function firstFunction(req, res) {
    console.log("First function");
  },
  function secondFunction(req, res) {
    console.log("Second function");
  }
);
</code></pre>
<p>We now have multiple functions in the same route.</p>
<p>But the first function does not automatically move to the second one.</p>
<p>That's where <code>next()</code> comes in.</p>
<h2>Where does <code>next()</code> come from?</h2>
<pre><code class="language-js">app.get("/users", (req, res, next) =&gt; {
  console.log("First function");
  next();
});
</code></pre>
<p>When Express calls this function, it provides:</p>
<pre><code class="language-text">req
res
next
</code></pre>
<p><code>req</code> is the request.</p>
<p><code>res</code> is the response.</p>
<p><code>next</code> is a function Express gives us to continue to the next matching function.</p>
<p>Now we can write:</p>
<pre><code class="language-js">app.get(
  "/users",
  (req, res, next) =&gt; {
    console.log("First function");
    next();
  },
  (req, res) =&gt; {
    res.send("Users");
  }
);
</code></pre>
<p>The flow is:</p>
<pre><code class="language-text">Request
   ↓
Function 1
   ↓
next()
   ↓
Function 2
   ↓
Response
</code></pre>
<p>The next function can be another function in the same <code>app.get()</code>:</p>
<pre><code class="language-js">app.get(
  "/users",
  first,
  second,
  third
);
</code></pre>
<p>Or <code>next()</code> can continue into another matching handler or middleware registered separately:</p>
<pre><code class="language-js">app.use(first);

app.get("/users", second);
</code></pre>
<p>So the request moves through the matching functions Express has registered.</p>
<h2>Multiple functions can also be passed as an array</h2>
<p>Express also lets you pass callback functions as an array:</p>
<pre><code class="language-js">app.get("/users", [
  firstFunction,
  secondFunction,
  thirdFunction
]);
</code></pre>
<p>You can also mix arrays and individual functions:</p>
<pre><code class="language-js">app.get(
  "/users",
  firstFunction,
  [secondFunction, thirdFunction],
  fourthFunction
);
</code></pre>
<p>They are still treated as a chain of functions.</p>
<p>An array is useful when you want to group related functions and reuse them:</p>
<pre><code class="language-js">const userChecks = [
  checkUser,
  validateUser,
  loadUser
];

app.get("/users", userChecks, getUsers);
</code></pre>
<p>So these are different ways of giving Express a chain of functions:</p>
<pre><code class="language-text">Function 1, Function 2, Function 3

or

[Function 1, Function 2, Function 3]

or

Function 1, [Function 2, Function 3], Function 4
</code></pre>
<h2>What is middleware?</h2>
<p>Now the definition is simple:</p>
<blockquote>
<p><strong>Middleware is a function that participates in the request-response cycle.</strong></p>
</blockquote>
<p>For example:</p>
<pre><code class="language-js">app.use((req, res, next) =&gt; {
  console.log(req.method, req.url);
  next();
});
</code></pre>
<p>There is nothing special about <code>app.use()</code> itself.</p>
<p>A middleware-style function can also be used with a route:</p>
<pre><code class="language-js">app.get("/users", (req, res, next) =&gt; {
  console.log("Checking request");
  next();
});
</code></pre>
<p>We generally use <code>app.use()</code> when we want something to apply across methods and matching paths.</p>
<p>The function is the middleware.</p>
<p><code>app.use()</code> is simply one way to register it.</p>
<h2>What can middleware do?</h2>
<p>Middleware can:</p>
<ul>
<li><p>run some logic</p>
</li>
<li><p>read or modify <code>req</code></p>
</li>
<li><p>read or modify <code>res</code></p>
</li>
<li><p>send a response</p>
</li>
<li><p>call <code>next()</code> to continue</p>
</li>
</ul>
<p>For example:</p>
<pre><code class="language-js">app.use((req, res, next) =&gt; {
  console.log(req.method, req.url);
  next();
});
</code></pre>
<p>The flow is:</p>
<pre><code class="language-text">Middleware
    ↓
Do some work
    ↓
next()
    ↓
Continue
</code></pre>
<p>Middleware is commonly placed before the routes that need it, so the request can pass through it first.</p>
<h2>Middleware can stop the request</h2>
<p>Middleware does not always have to call <code>next()</code>.</p>
<pre><code class="language-js">app.use((req, res, next) =&gt; {
  if (!req.headers.authorization) {
    return res.status(401).send("Unauthorized");
  }

  next();
});
</code></pre>
<p>The flow is:</p>
<pre><code class="language-text">             Request
                ↓
           Middleware
           /        \
      Reject       Continue
        ↓             ↓
    Response        next()
                      ↓
                 Next function
</code></pre>
<p>So middleware can either continue the chain or end the request.</p>
<h2>Middleware can pass data forward</h2>
<p>The same request object moves through the chain.</p>
<p>That means one middleware can attach data to it:</p>
<pre><code class="language-js">app.use((req, res, next) =&gt; {
  req.user = {
    id: 123
  };

  next();
});

app.get("/profile", (req, res) =&gt; {
  res.json(req.user);
});
</code></pre>
<p>The flow is:</p>
<pre><code class="language-text">Request
   ↓
Middleware
   ↓
req.user = ...
   ↓
Route Handler
   ↓
Response
</code></pre>
<p>This is one of the main reasons middleware is useful.</p>
<h2>Multiple middleware functions</h2>
<p>You can chain several functions:</p>
<pre><code class="language-js">app.get(
  "/profile",
  checkLogin,
  checkProfile,
  loadProfile,
  showProfile
);
</code></pre>
<pre><code class="language-text">Request
   ↓
checkLogin
   ↓
checkProfile
   ↓
loadProfile
   ↓
showProfile
   ↓
Response
</code></pre>
<p>Each function can do some work and call <code>next()</code>.</p>
<h2>Middleware vs route handler</h2>
<p>They use the same basic function mechanism, but usually have different jobs.</p>
<h3>Route handler</h3>
<p>Usually finishes the request:</p>
<pre><code class="language-js">app.get("/users", (req, res) =&gt; {
  res.json(users);
});
</code></pre>
<h3>Middleware</h3>
<p>Usually does some work before the final handler:</p>
<pre><code class="language-js">app.use((req, res, next) =&gt; {
  console.log("Request received");
  next();
});
</code></pre>
<p>But middleware can also send the response and end the request.</p>
<p>The difference is mainly about the function's role in the request flow.</p>
<h2>What exactly does <code>next()</code> do?</h2>
<p><code>next()</code> means:</p>
<blockquote>
<p>Continue this current request with the next matching function.</p>
</blockquote>
<p>It does <strong>not</strong> mean "next request."</p>
<p>Also, <code>next()</code> does not stop the current JavaScript function automatically.</p>
<p>Consider:</p>
<pre><code class="language-js">app.get(
  "/users",
  (req, res, next) =&gt; {
    next();

    res.send("Hello");
  },
  (req, res) =&gt; {
    res.send("Users");
  }
);
</code></pre>
<p>When <code>next()</code> is called, Express continues to the next function.</p>
<p>That function sends:</p>
<pre><code class="language-text">Users
</code></pre>
<p>The earlier function has not automatically stopped.</p>
<p>After the next function finishes, JavaScript can continue from where the earlier function called <code>next()</code>.</p>
<p>So this line can then run:</p>
<pre><code class="language-js">res.send("Hello");
</code></pre>
<p>Now we are trying to send another response for the same request.</p>
<p>That can cause an error such as:</p>
<pre><code class="language-text">Can't set headers after they are sent
</code></pre>
<p>In simple words, <strong>headers are small pieces of information sent with the response</strong>, such as content type and other response details.</p>
<p>Once the response has already been sent, you cannot send another response for the same request.</p>
<p>This is also why understanding JavaScript functions, the call stack, and execution flow is useful when working with Express.</p>
<p>If you want to understand this part deeply, callbacks, execution context, the call stack, and how V8 runs JavaScript are worth learning separately.</p>
<h2>Error-handling middleware</h2>
<p>First, what is error-handling middleware?</p>
<p>It is simply a middleware function whose job is to handle errors.</p>
<p>Express identifies it by its four-argument signature:</p>
<pre><code class="language-js">(err, req, res, next)
</code></pre>
<p>For example:</p>
<pre><code class="language-js">app.use((err, req, res, next) =&gt; {
  res.status(500).json({
    error: err.message
  });
});
</code></pre>
<p>An error can be passed with:</p>
<pre><code class="language-js">next(err);
</code></pre>
<p>When Express receives an error, it skips the remaining normal middleware and route handlers and looks for the next error-handling middleware.</p>
<p>For example:</p>
<pre><code class="language-text">Middleware 1
    ↓
Middleware 2
    ↓
   Error
    ↓
next(err)
    ↓
Skip normal handlers
    ↓
Nearest matching error handler
    ↓
Response
</code></pre>
<p>If there are several error handlers, Express uses the next matching error handler in the chain.</p>
<p>If that error handler calls <code>next(err)</code>, Express continues looking for another error handler.</p>
<p>If your application has no custom error handler that handles the error, Express has a built-in error handler.</p>
<h2>Types of Express middleware</h2>
<p>Express commonly describes five types.</p>
<h3>1. Application-level middleware</h3>
<p>This is middleware attached to the main Express app.</p>
<p>You can register it with <code>app.use()</code>:</p>
<pre><code class="language-js">app.use(logger);
</code></pre>
<p>Or with a specific HTTP method:</p>
<pre><code class="language-js">app.get("/users", checkLogin);
</code></pre>
<p>For example:</p>
<pre><code class="language-js">app.use((req, res, next) =&gt; {
  console.log("Request received");
  next();
});
</code></pre>
<p>This runs for requests that reach this point in the app.</p>
<p>You can also limit it to a path:</p>
<pre><code class="language-js">app.use("/api", logger);
</code></pre>
<p>Now it applies to requests under <code>/api</code>.</p>
<p>Another example:</p>
<pre><code class="language-js">app.use(express.json());
app.use("/api", checkLogin);
</code></pre>
<p>Think of application-level middleware as:</p>
<pre><code class="language-text">Middleware attached to the main app
</code></pre>
<h3>2. Router-level middleware</h3>
<p>Router-level middleware works the same way, but it is attached to an <code>express.Router()</code> instead of the main app.</p>
<p>For example:</p>
<pre><code class="language-js">const router = express.Router();

router.use(checkLogin);

router.get("/profile", showProfile);
router.get("/orders", showOrders);
</code></pre>
<p>Here, <code>checkLogin</code> applies to the routes inside that router.</p>
<p>You can also attach it to one route:</p>
<pre><code class="language-js">router.get("/profile", checkLogin, showProfile);
</code></pre>
<p>And mount the router on the main app:</p>
<pre><code class="language-js">app.use("/account", router);
</code></pre>
<p>Now the structure looks like:</p>
<pre><code class="language-text">app
  ↓
/account router
  ↓
router middleware
  ↓
router route
</code></pre>
<p>Router-level middleware is useful when you want to keep related routes and their middleware together.</p>
<h3>3. Error-handling middleware</h3>
<p>This middleware handles errors:</p>
<pre><code class="language-js">app.use((err, req, res, next) =&gt; {
  res.status(500).send("Something went wrong");
});
</code></pre>
<p>Another simple example:</p>
<pre><code class="language-js">app.use((err, req, res, next) =&gt; {
  console.error(err.message);
  next(err);
});
</code></pre>
<p>You can also have more than one:</p>
<pre><code class="language-js">app.use(logError);
app.use(sendErrorResponse);
</code></pre>
<h3>4. Built-in middleware</h3>
<p>These are middleware functions provided by Express.</p>
<p>For example:</p>
<pre><code class="language-js">app.use(express.json());
</code></pre>
<p>This parses JSON request bodies.</p>
<p>Another:</p>
<pre><code class="language-js">app.use(express.urlencoded({ extended: true }));
</code></pre>
<p>And:</p>
<pre><code class="language-js">app.use(express.static("public"));
</code></pre>
<p>This serves static files.</p>
<p>Think:</p>
<pre><code class="language-text">Built into Express
→ use it directly
</code></pre>
<h3>5. Third-party middleware</h3>
<p>These come from external npm packages.</p>
<p>For example:</p>
<pre><code class="language-js">const cors = require("cors");

app.use(cors());
</code></pre>
<p>Another common example:</p>
<pre><code class="language-js">const cookieParser = require("cookie-parser");

app.use(cookieParser());
</code></pre>
<p>And:</p>
<pre><code class="language-js">const morgan = require("morgan");

app.use(morgan("dev"));
</code></pre>
<p>Think:</p>
<pre><code class="language-text">Third-party package
→ install it
→ register it
→ use its middleware
</code></pre>
<p>You don't need to memorize these five categories.</p>
<p>The important thing is understanding what middleware is and where it can be attached.</p>
<h2>The mental model</h2>
<p>Everything comes back to this:</p>
<pre><code class="language-text">Client
  ↓
Request
  ↓
Middleware
  ↓
Middleware
  ↓
Route Handler
  ↓
Response
  ↓
Client
</code></pre>
<p>At any step, a function can:</p>
<pre><code class="language-text">Do some work
    ↓
Modify req/res
    ↓
Send a response

or

next()
    ↓
Continue the chain

or

next(err)
    ↓
Go to error handling
</code></pre>
<p>Once you understand routes, callbacks, chained functions, <code>next()</code>, and the request-response flow, middleware becomes a very small concept.</p>
<p><code>app.use()</code> is one way to register middleware.</p>
<p><code>next()</code> moves the current request forward.</p>
<p>And middleware is simply the name we give to functions that participate in that request-processing flow.</p>
]]></content:encoded></item><item><title><![CDATA[The Internet: How It Works and Why It Matters]]></title><description><![CDATA[Ever imagined what happens when you type a URL in the address bar of the browser and hit enter?
What happens when you click on a link?
What is the Internet? How does the Web work?
What is client, server, https, domain name system server, etc.? What d...]]></description><link>https://ajaypanigrahi.hashnode.dev/how-the-internet-works-and-why-it-matters</link><guid isPermaLink="true">https://ajaypanigrahi.hashnode.dev/how-the-internet-works-and-why-it-matters</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[internet]]></category><category><![CDATA[How the internet works ]]></category><category><![CDATA[dns resolver]]></category><category><![CDATA[dns]]></category><category><![CDATA[http]]></category><category><![CDATA[client-server]]></category><dc:creator><![CDATA[Ajay B Panigrahi]]></dc:creator><pubDate>Thu, 23 Jan 2025 13:42:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1737639529187/88d3e8e6-cac5-4d0a-8041-dba716a1d57f.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Ever imagined what happens when you type a URL in the address bar of the browser and hit enter?</p>
<p>What happens when you click on a link?</p>
<p>What is the Internet? How does the Web work?</p>
<p>What is client, server, https, domain name system server, etc.? What do we mean by these jargons?</p>
<p>By the end of this article, you will be well versed in the Internet and all its related technology!</p>
<h1 id="heading-what-is-internet">What is Internet?</h1>
<p>The <strong>Internet</strong> is a global network of interconnections of computers. It's like a big spider web where each node of the web is like a computer. The Internet, in simple words, is the connection of all the computers in the world. As the computers are interconnected due to this network "Internet,“ they can talk with each other, communicate, and exchange information.</p>
<p>For example, a person in India using his computer can communicate with another computer used by the person in the USA. They can send emails, pictures, and pdf’s to each other. Thanks to the Internet.</p>
<p><img src="https://plus.unsplash.com/premium_photo-1683836722608-60ab4d1b58e5?q=80&amp;w=2012&amp;auto=format&amp;fit=crop&amp;ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" alt class="image--center mx-auto" /></p>
<h2 id="heading-let-us-understand-the-internet-in-depth-with-a-diagram">Let us understand the Internet in depth with a diagram.</h2>
<p>We understood the main work and meaning of the internet - linking computers and communicating with one another. Exchanging information was the main goal of the Internet.</p>
<p>We understood the concept of the Internet, but still, how does a website stored on the server get loaded in your browser just by typing the URL? How does all this happen? Is it magic? Let's understand the inner engineering of this masterpiece, <strong>Internet</strong>.</p>
<p>When we type URL (fancy name for link) in the browser, the website gets loaded. So this happens due to the client server architecture and its request response model.</p>
<h2 id="heading-client-server-architecturerequest-response-model">Client - Server Architecture(Request Response Model)</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1737630950573/c87d309e-7e21-4519-99f3-8894762eed34.png" alt class="image--center mx-auto" /></p>
<p>So when <strong>client</strong>(user/device/browser) enters the URL(link) in the browser, a request is made to the <strong>server</strong>(a machine that contains your website code and runs 24×7). The server(machine containing your website code) then sends a response back with the website code, and this code is rendered by the browser, and you can see the website.</p>
<p>So in simple terms, the client (user) sends a request to the server (the machine containing the website’s code), and the server in return sends the website's code as a response. This website's code is rendered by the browser, and successfully you can see the website and use it.</p>
<h2 id="heading-what-is-http">What is HTTP?</h2>
<p><strong>HTTP</strong> stands for <strong>HyperText Transfer Protocol</strong>. Http is basically a set of rules used to transfer the web document containing hyperlinks (plain old links).</p>
<p>So some rules are to be followed if we need to send a web/text document containing links; this is the primary role of HTTP. So while communicating between systems, we follow the HTTP.</p>
<p><img src="https://cdn.pixabay.com/photo/2012/02/16/12/09/search-13476_1280.jpg" alt class="image--center mx-auto" /></p>
<h2 id="heading-lets-go-a-bit-more-in-depth-about-client-server-communication">Let's go a bit more in depth about client-server communication.</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1737637739564/5694e108-e682-4cde-8a37-5ce730bdeb55.png" alt class="image--center mx-auto" /></p>
<p>As shown in the above diagram, the client-server communication is not that simple; it's quite complicated. Let's try to understand in simple layman's terms. The client sends a request to the server, and the server, in return, sends a response as files containing the website’s code, but how does the browser (client) know the address of the server where the website is stored? We only know the name of the website (domain name), for example, google.com, but how, by just typing google.com in the browser, does it reach the server, as the client (browser) does not know the address of the server where the website is stored?</p>
<p>This address of the server is found by translating the domain name (name of the website, for example, google.com) into its corresponding IP address, and this IP address is the address of the server where the website's code is stored. This translation of domain to IP address is done by the Domain Name System Server (DNS Server). In the above diagram, you can see how complex the process of translating a domain to an IP is; this process of translating a domain to an IP is called DNS Resolution. It's a bit complex; it involves communicating with root servers and their top-level domains, then the authoritative name server, and so on, until the IP address of the website is not returned by the DNS to the browser.</p>
<p>Once we get the IP address of the server, we then use HTTP to communicate with the server, and then the request-response cycle continues…</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>The Internet is a global network of interconnected computers. Using the Internet, computers communicate with each other.</p>
<p>There’s a lot in terms of loading a URL; the client sends a request to the server, and the server sends a response giving the website’s code. The client uses HTTPS to communicate. For the client to communicate with the server using HTTPS, first it needs to know the IP address of the server. We get the IP address of the server from the DNS server; it does DNS resolution and gives us the IP address of the server, and then we use HTTP to communicate with the server(and then the request response cycle goes on).</p>
]]></content:encoded></item><item><title><![CDATA[The Jargons of the Internet]]></title><description><![CDATA[1) What is a Computer?
A machine that processes information, stores data, performs calculations and run programs.
(Computer ek aisi machine hai jo data process karti hai, calculations karti hai, aur programs chalati hai.)

2) What is the Internet?
A ...]]></description><link>https://ajaypanigrahi.hashnode.dev/the-jargons-of-the-internet</link><guid isPermaLink="true">https://ajaypanigrahi.hashnode.dev/the-jargons-of-the-internet</guid><category><![CDATA[chai-code ]]></category><category><![CDATA[computer]]></category><category><![CDATA[internet]]></category><category><![CDATA[http]]></category><category><![CDATA[https]]></category><category><![CDATA[TCP]]></category><category><![CDATA[UDP]]></category><category><![CDATA[ip address]]></category><category><![CDATA[domain]]></category><category><![CDATA[dns server]]></category><category><![CDATA[protocols]]></category><category><![CDATA[throttling]]></category><category><![CDATA[ChaiCode]]></category><category><![CDATA[chai aur code]]></category><category><![CDATA[Chaiaurcode]]></category><dc:creator><![CDATA[Ajay B Panigrahi]]></dc:creator><pubDate>Sun, 12 Jan 2025 13:04:42 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1736675046481/8edfb81a-e055-4b31-9f19-60e8afde4f27.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<hr />
<h2 id="heading-1-what-is-a-computer">1) What is a Computer?</h2>
<p>A machine that processes information, stores data, performs calculations and run programs.</p>
<p>(Computer ek aisi machine hai jo data process karti hai, calculations karti hai, aur programs chalati hai.)</p>
<p><img src="https://images.pexels.com/photos/1779487/pexels-photo-1779487.jpeg?auto=compress&amp;cs=tinysrgb&amp;w=1260&amp;h=750&amp;dpr=1" alt="Computer" class="image--center mx-auto" /></p>
<h2 id="heading-2-what-is-the-internet">2) What is the Internet?</h2>
<p>A massive network connecting millions of computers worldwide, allowing them to exchange information. It’s like a big spider web, where each computer is a node connected by threads.</p>
<p>(Internet duniya bhar ke computers ko connect karta hai, jaise ek invisible spider web. Har computer ek node hai jo information exchange kar sakta hai.)</p>
<p><img src="https://cdn.pixabay.com/photo/2016/04/04/14/12/monitor-1307227_960_720.jpg" alt="Internet" class="image--center mx-auto" /></p>
<h2 id="heading-3-what-is-http">3) What is HTTP?</h2>
<p>It stands for <strong>HyperText Transfer Protocol</strong>. Before understanding HTTP, let’s first understand the last word in it “<strong>Protocol</strong>”.</p>
<p><strong>Protocol</strong>: A set of rules that computers follow to communicate. It’s like a language they all agree on.<br />(Protocol woh rules ka set hai jo computers ko ek doosre se baat karne ke liye follow karna padta hai.)</p>
<p><strong>HTTP (HyperText Transfer Protocol)</strong>: A protocol that allows computers to share information, such as web pages. It’s what happens when you type a URL and hit Enter, your browser follows HTTP rules to fetch the web page from the server.<br />(HTTP ek protocol hai jo web pages ko server se browser tak lane ka kaam karta hai.)</p>
<p><img src="https://cdn.pixabay.com/photo/2012/02/16/12/09/search-13476_1280.jpg" alt="HyperText Transfer Protocol" class="image--center mx-auto" /></p>
<h2 id="heading-4-what-is-the-request-response-cyclemodel">4) What is the Request-Response Cycle/Model?</h2>
<p>It is a system where your computer (client/browser/user agent) makes a request, and another computer (server/backend) responds.<br />So, you make a request, and in return, you get a response.</p>
<p>(<strong><em>Request-response model ek system hai jisme ek computer kuch maangta hai (request), aur doosra computer uska jawab deta hai (response).</em></strong>)</p>
<p><img src="https://miro.medium.com/v2/resize:fit:853/1*8-fT6K1o6nHiBRxKppcqOg.png" alt="https://miro.medium.com/v2/resize:fit:853/1*8-fT6K1o6nHiBRxKppcqOg.png" class="image--center mx-auto" /></p>
<h2 id="heading-5-what-are-http-headers">5) What are HTTP Headers?</h2>
<p>HTTP headers are extra pieces of information sent with a request or response, similar to how your name or return address appears on an envelope.</p>
<p>(HTTP headers wo extra details hai jo request-response ke saath bheji jati hai.)</p>
<p><img src="https://cdn.prod.website-files.com/5ff66329429d880392f6cba2/6720dff9eada99162c95b2d5_6720d2aac712d878f3a3eb97_2%2520-%252029.10-min.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-6-what-is-a-stateless-protocol-why-is-http-a-stateless-protocol">6) What is a Stateless Protocol? (Why is HTTP a Stateless Protocol?)</h2>
<p>A stateless protocol (like HTTP) doesn't retain information about previous interactions. It's like meeting a new person each time, no memory of past conversations.</p>
<p>In simple words it doesnot remember the memory of previous requests.</p>
<p>(HTTP stateless hai, matlab use kuch yaad nahi rehta. HTTP ko pehle ki baatein yaad nahi rehti)</p>
<h2 id="heading-7-what-are-sessions-cookies-cache-local-storage-and-how-do-they-differ-from-each-other">7) What are Sessions, Cookies, Cache, Local Storage and how do they differ from each other?</h2>
<ol>
<li><p><strong>Session</strong>: Stores temporary data during your visit and ends when you close the browser.<br /> <strong>Example</strong>: Keeps you logged in while you're on the site.</p>
<p> <em>(Temporary data jo aapke visit ke dauran store hota hai aur browser band karne par khatam ho jata hai.<br /> Udharan: Jab tak aap site pe hote hain, aap login rehte hain.)</em></p>
</li>
<li><p><strong>Cookie</strong>:<br /> Stores small data (small piece of info) to remember things across visits, like login details or preferences (they are key-value pairs).<br /> <strong>Example</strong>: Remembers your language choice next time you visit.</p>
<p> <em>(Chhoti data (key-value pairs) jo aapki preferences ya login details ko store karte hain, jo future visits pe yaad rehti hain.<br /> Udharan: Aapki language choice yaad rehti hai jab aap dobara visit karte hain.)</em></p>
</li>
<li><p><strong>Cache</strong>:<br /> Saves website files (like images) to load pages faster on future visits (speeds up the website).<br /> <strong>Example</strong>: Images load quicker because they're saved locally.</p>
<p> <em>(Website ke files (jaise images) ko save karta hai, jisse agle visit pe website jaldi load ho.<br /> Udharan: Images jaldi load hoti hain kyunki wo locally save hoti hain.)</em></p>
</li>
<li><p><strong>Local Storage</strong>:<br /> Saves larger data on your device for a longer time, even after the browser is closed.<br /> <strong>Example</strong>: Remembers your website preferences (e.g., theme) across visits.</p>
<p> <em>(Lambe samay tak data save karta hai, browser band hone ke baad bhi.<br /> Udharan: Aapke website preferences (jaise theme) yaad rakhta hai har visit pe.)</em></p>
</li>
</ol>
<h3 id="heading-key-differences"><strong>Key Differences</strong>:</h3>
<ul>
<li><p><strong>Session</strong>: Temporary data that lasts until the browser is closed.</p>
<p>  (<strong>Session</strong>: Temporary data jo browser band hone tak rehta hai.)</p>
</li>
<li><p><strong>Cookie</strong>: Small data stored across sessions, sent to the server with requests.</p>
<p>  (<strong>Cookie</strong>: Chhoti data jo sessions ke beech store hoti hai aur server ko bheji jaati hai.)</p>
</li>
<li><p><strong>Cache</strong>: Stores resources to speed up loading times on future visits.</p>
<p>  (<strong>Cache</strong>: Website ke resources ko store karta hai taaki future visits pe website jaldi load ho.)</p>
</li>
<li><p><strong>Local Storage</strong>: Stores larger data persistently on the client-side, even after the browser is closed.</p>
<p>  (<strong>Local Storage</strong>: Zyada data store karta hai jo client side pe rehta hai aur browser band hone ke baad bhi rehta hai.)</p>
</li>
</ul>
<h2 id="heading-8-what-is-the-difference-between-http-and-https">8) What is the difference between HTTP and HTTPS?</h2>
<p><strong>HTTP</strong>: A protocol that sends data in plain text, not secure.<br /><strong>(HTTP mein data secure nahi hota.)</strong></p>
<p><strong>HTTPS</strong>: A secure version of HTTP that uses encryption to protect data, along with features like <strong>compression</strong> (reducing data size) and <strong>multiplexing</strong> (sending multiple files at once) to speed up communication.<br /><strong>(HTTPS mein data encrypted hota hai, aur compression aur multiplexing ka use karke data transfer ko fast banaya jata hai.)</strong></p>
<p><img src="https://cdn.prod.website-files.com/64555bfdcb110dbf3e9e04bd/646cf41e9c60c23fcea5be7a_HTTP-vs-HTTPS.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-9-what-are-ssl-and-tls">9) <strong>What are SSL and TLS?</strong></h2>
<p><strong>SSL</strong> (Secure Sockets Layer) was introduced in 1994 to secure web traffic by encrypting data.</p>
<p><strong>TLS</strong> (Transport Layer Security) is a more secure version of SSL, and it's now widely used to protect data in modern web communication.</p>
<p><strong>(SSL pehle tha, lekin ab TLS use hota hai, jo zyada secure hai</strong> aur certificates batate hain taki website trust karne layak hoo.<strong>)</strong></p>
<p><img src="https://i0.wp.com/lab.wallarm.com/wp-content/uploads/2023/10/Table_-SSL-vs.-TLS-min.jpg?w=770&amp;ssl=1" alt class="image--center mx-auto" /></p>
<h2 id="heading-10-what-is-ip"><strong>10) What is IP?</strong></h2>
<p><strong>IP</strong> (Internet Protocol) is a unique address assigned to every device connected to the internet. <strong>It identifies devices and helps them communicate over a network.</strong></p>
<p><strong>(IP ek unique address hota hai jo har device ko internet par milta hai, jisse wo devices ek dusre se communicate kar sakte hain.)</strong></p>
<p><img src="https://images.pexels.com/photos/11035359/pexels-photo-11035359.jpeg?auto=compress&amp;cs=tinysrgb&amp;w=1260&amp;h=750&amp;dpr=1" alt class="image--center mx-auto" /></p>
<h2 id="heading-11-what-is-domain"><strong>11) What is Domain?</strong></h2>
<p><strong>Human-friendly names for websites</strong> (e.g., <a target="_blank" href="http://google.com">google.com</a>). <strong>The human-readable form of an IP address.</strong></p>
<p><strong>(Domain ek website ka naam hota hai.)</strong></p>
<p><img src="https://storage.googleapis.com/dopingcloud/blog/en/2022/04/what-is-domain-name-960x640.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-12-what-is-url"><strong>12) What is URL?</strong></h2>
<p>The complete address of a web page.</p>
<p><img src="https://cdn.prod.website-files.com/64949e4863d96e26a1da8386/64f5f56c78d05cf501922f99_64a2ef9774661044d9755e98_URL%2520-%2520Glossary.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-13-what-is-dns"><strong>13) What is DNS?</strong></h2>
<p>A system that translates domain names into IP addresses (like a phonebook).</p>
<p><strong>(DNS domain ko IP address mein convert karta hai, taki browser ko pata chale ki data kahan se lana hai.)</strong></p>
<p><img src="https://3hcloud.com/upload/iblock/9d6/kfrr68vw758agzejb9n7igucy6b5aajw/dns.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-14-what-is-client"><strong>14) What is Client?</strong></h2>
<p>The computer or browser that asks for something.</p>
<p><strong>(Client request karta hai.)</strong></p>
<p><img src="https://www.hubspot.com/hs-fs/hubfs/clientvscustomer_2.webp?width=595&amp;height=400&amp;name=clientvscustomer_2.webp" alt class="image--center mx-auto" /></p>
<h2 id="heading-15-what-is-server"><strong>15) What is Server?</strong></h2>
<p>The computer that provides the requested information.</p>
<p><strong>(Server reply deta hai.)</strong></p>
<p><img src="https://www.techfinitive.com/wp-content/uploads/2023/02/what-is-a-server-jpg.webp" alt class="image--center mx-auto" /></p>
<h2 id="heading-16-what-is-frontend"><strong>16) What is Frontend?</strong></h2>
<p>The visible part of a website.</p>
<p><strong>(Frontend wo hota hai jo user dekhta hai.)</strong></p>
<p><img src="https://kinsta.com/wp-content/uploads/2021/11/front-end-developer-1024x512.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-17-what-is-backend"><strong>17) What is Backend?</strong></h2>
<p>The hidden part that processes requests.</p>
<p><strong>(Backend wo hota hai jo behind-the-scenes kaam karta hai.)</strong></p>
<p><img src="https://miro.medium.com/v2/resize:fit:1400/0*lQJUG355unpGw_fQ" alt class="image--center mx-auto" /></p>
<h2 id="heading-18-what-is-tcp"><strong>18) What is TCP?</strong></h2>
<p><strong>TCP</strong> (Transmission Control Protocol) is a reliable, connection-oriented protocol that ensures data is delivered correctly and in order.</p>
<p><strong>(TCP reliable hai, data sahi order mein aur bina errors ke bhejta hai.)</strong></p>
<p><img src="https://www.cheggindia.com/wp-content/uploads/2023/09/tcp-full-form.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-19-what-is-udp"><strong>19) What is UDP?</strong></h2>
<p><strong>UDP</strong> (User Datagram Protocol) is a fast, connectionless protocol that sends data without guaranteeing delivery or order.</p>
<p><strong>(UDP fast hai, lekin delivery aur order ki guarantee nahi deta.)</strong></p>
<p><img src="https://cheapsslsecurity.com/blog/wp-content/uploads/2022/06/how-udp-works-feature.jpg" alt class="image--center mx-auto" /></p>
<h2 id="heading-20-what-is-ftp"><strong>20) What is FTP?</strong></h2>
<p><strong>FTP</strong> (File Transfer Protocol) is used to transfer files between computers using <strong>TCP</strong> for reliable communication.</p>
<p>(<strong>FTP files transfer karne ke liye hota hai, aur TCP ko use karta hai data ko reliably bhejne ke liye.)</strong></p>
<p><img src="https://www.filestash.app/img/posts/2021-07-27-getting-started-with-a-ftp-server_0.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-21-what-is-the-difference-between-tcp-udp-and-ftp"><strong>21)</strong> What is the difference between TCP, UDP and FTP?</h2>
<ul>
<li><p><strong>TCP</strong>: Reliable, slower, ensures correct delivery.</p>
</li>
<li><p><strong>UDP</strong>: Unreliable, faster, no guarantee.</p>
</li>
<li><p><strong>FTP</strong>: File transfer protocol using <strong>TCP</strong> for reliable transfers.</p>
</li>
</ul>
<p><strong>(TCP reliable hai, UDP fast hai aur FTP file transfer ke liye use hota hai.)</strong></p>
<h2 id="heading-22-what-is-payload">22) <strong>What is Payload?</strong></h2>
<p><strong>Payload</strong> refers to the actual data being sent in a network packet, excluding the headers and metadata.</p>
<p><strong>(Payload wo asli data hota hai jo network pe send kiya jata hai, headers aur extra information ke bina.)</strong></p>
<h2 id="heading-23-what-is-voip"><strong>23) What is VOIP?</strong></h2>
<p><strong>VOIP</strong> (Voice over Internet Protocol) allows voice communication over the internet instead of traditional phone lines.</p>
<p><strong>(VOIP internet ke through voice calls karne ka tareeka hai, jo traditional phone lines ki jagah use hota hai.)</strong></p>
<p><img src="https://www.uctoday.com/wp-content/uploads/2023/03/What-Is-a-VoIP-Phone-An-Introductory-Guide-.jpg" alt class="image--center mx-auto" /></p>
<h2 id="heading-24-what-are-ports-and-how-many-are-there-in-a-computer">24) What are ports and how many are there in a computer?</h2>
<p>Ports are virtual channels that allow services or apps to communicate over a network, like doors on your computer. Each service uses a specific port (e.g., port 80 for browsing). <strong>(Ports wo virtual channels hote hain jo services ya apps ko network par connect karte hain, jaise doors jo computer ko services se connect karte hain.)</strong></p>
<p>There are 65,535 ports in a computer. <strong>(Computer mein 65,535 ports hote hain.)</strong></p>
<h2 id="heading-25-what-is-throttling">25) What is Throttling?</h2>
<p><strong>Throttling</strong> is the practice of limiting the amount of data or requests a user can send to a service or server to prevent overload. <strong>(Throttling ka matlab hai data ya requests ki limit laga dena taaki service ya server overload na ho.)</strong></p>
<p>It is used to manage server load and ensure fair usage. <strong>(Yeh server ka load manage karne aur fair usage ensure karne ke liye use hota hai.)</strong></p>
]]></content:encoded></item></channel></rss>