<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aditya Singh on Medium]]></title>
        <description><![CDATA[Stories by Aditya Singh on Medium]]></description>
        <link>https://medium.com/@adiii11?source=rss-80e62d7a00a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*vNjqvdSjBvcc-kQmphh8uw.png</url>
            <title>Stories by Aditya Singh on Medium</title>
            <link>https://medium.com/@adiii11?source=rss-80e62d7a00a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:13:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adiii11/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A quick overview to Docker ]]></title>
            <link>https://medium.com/@adiii11/a-quick-overview-to-docker-cfadd52a380d?source=rss-80e62d7a00a------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfadd52a380d</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Aditya Singh]]></dc:creator>
            <pubDate>Mon, 26 Jan 2026 09:02:26 GMT</pubDate>
            <atom:updated>2026-01-26T09:02:26.157Z</atom:updated>
            <content:encoded><![CDATA[<p>As an engineer, I use Docker commands daily to run my applications. If you’re also someone who needs a quick overview of Docker along with the commonly used commands, you’re in the right place.</p><h4>What is Docker? And why do we need it?</h4><p>Docker is a tool that lets you package an application <strong>with everything it needs to run - </strong>code, runtime, system libraries, environment variables - into a single, portable unit called a “<em>container”</em>.</p><p>Before Docker, software had a bad habit of working perfectly on one machine and mysteriously breaking on another. Different OS versions, missing dependencies, mismatched configs. Docker exists to kill that problem.</p><h4>Everyday commands that every developer should know</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*PAVAxGlU1AW995XNSe9WOg.png" /></figure><h3>Let’s understand the basic terms used above</h3><h4>Dockerfile = the recipe</h4><p>A Dockerfile is a plain text file that tells Docker “<em>how to build an image”</em>.</p><p>It answers questions like:</p><ul><li>Which base environment do we start from?</li><li>What dependencies should be installed?</li><li>How do we copy the code?</li><li>What command should run when the container starts?</li></ul><p>This is where you define your environment once and stop relying on tribal knowledge.</p><h4>Image = a frozen recipe</h4><p>A Docker image is a built, read-only blueprint of your application.<br> It contains:</p><ul><li>Your code</li><li>Dependencies</li><li>Runtime (Node, Python, Java, etc.)</li><li>System-level requirements</li></ul><p>Think of it like a frozen recipe box. Everything needed is already inside. Images don’t do anything by themselves. They just sit there, immutable and reusable.</p><h4>Container = a running image</h4><p>A container is what happens when you run an image.</p><p>If the image is a photo, the container is the living thing.<br>If the image is the recipe, the container is the dish on the table.</p><p>Containers:</p><ul><li>Are isolated from each other</li><li>Can be started, stopped, restarted, and destroyed</li><li>Share the same image but have their own runtime state</li></ul><p>You can run ten containers from the same image, and each will behave independently.</p><h4>docker-compose = the restaurant manager</h4><p>Real applications rarely run alone. You usually need:</p><ul><li>A backend</li><li>A database</li><li>A cache</li><li>Maybe a frontend</li></ul><p>That’s where docker-compose comes in.</p><p>docker-compose is a tool that lets you define and run <strong>multiple containers together</strong>. It wires them up, gives them networks, sets environment variables, and starts everything in the right order.</p><p>If Docker runs a single dish, docker-compose runs the entire restaurant. <em>One command. Everything up.</em></p><h3>FAQs</h3><h4>Docker vs Virtual Machines: what’s actually different</h4><p>Imagine you want to house three families (which are your Applications):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zty9_LXl6CJuQ-7F0_dbOw.png" /></figure><h4>1. The Virtual Machine (VM) is like building 3 separate Houses.</h4><ul><li><strong>The Setup:</strong> For every family, you build a brand new house from scratch. Each house has its own foundation, its own plumbing, its own heating system, and its own roof.</li><li><strong>The Problem:</strong> This takes up a <strong>lot of land</strong> (computer memory/storage) and takes a <strong>long time to build</strong> (slow to start up). Even if a family is small, they still have to maintain an entire house setup.</li><li><strong>The Good Part:</strong> If one house catches fire (crashes or gets a virus), the other houses are totally safe because they are far apart.</li></ul><h4>2. Docker (Containers) is like an Apartment Building.</h4><ul><li><strong>The Setup:</strong> You build just <strong>one</strong> big building with a strong foundation and shared plumbing/heating (this is the <strong>Host OS/Kernel</strong>). Then, you just give each family their own apartment unit inside.</li><li><strong>The Benefit:</strong> It is super <strong>efficient</strong>. You aren’t wasting space building three separate heating systems. You can fit way more families into the same amount of land.</li><li><strong>The Speed:</strong> If a new family moves in, you just hand them a key. You don’t have to build a whole new house.</li></ul><p><strong>In short:</strong></p><ul><li><strong>VMs</strong> = Heavy, separate houses (Safe but expensive).</li><li><strong>Docker</strong> = Lightweight apartments (Fast and efficient).</li></ul><h3>When to use what?</h3><h4>Use Docker (Containers) when -</h4><ol><li><strong>You are building “Micro-services”:</strong> If your app is broken into 50 small pieces (login service, payment service, cart service), you don’t want 50 heavy Operating Systems running. Docker lets you pack them all tightly onto one server.</li><li><strong>You need Speed:</strong> You want your app to start in milliseconds, not minutes.</li><li><strong>You want “Portability”:</strong> You want to code on your MacBook, test on a Windows PC, and deploy to a Linux Cloud server, and have it work exactly the same everywhere.</li><li><strong>You want to save money:</strong> You can cram 5x more applications onto the same server hardware compared to VMs.</li></ol><h4>Use Virtual Machines (VMs) when -</h4><ol><li><strong>You need totally different Operating Systems:</strong> You have a Linux server, but one specific app <em>must</em> run on Windows. Docker shares the OS, so it can’t easily do this. A VM can run Windows on top of Linux.</li><li><strong>High Security / Isolation is priority #1:</strong> If you are running code from a customer you don’t trust, put it in a VM. If a Container gets hacked, it is <em>possible</em> (though hard) for the hacker to affect the host machine. If a VM gets hacked, they are trapped inside that virtual hard drive.</li><li><strong>Legacy Apps (The “Old Stuff”):</strong> You have a giant, clunky application built 10 years ago that is messy and hard to move. It’s often easier to just “lift and shift” the whole thing into a VM rather than trying to containerize it.</li></ol><p>Thanks for being till here, if you liked the blog, then do follow me for more such “<em>quick overview concepts</em>” :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfadd52a380d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Never imagined frontend would be this much of a headache]]></title>
            <link>https://medium.com/@adiii11/never-imagined-frontend-would-be-this-much-of-headache-bf55680cf4c2?source=rss-80e62d7a00a------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf55680cf4c2</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[caching]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[Aditya Singh]]></dc:creator>
            <pubDate>Sun, 07 Sep 2025 20:51:09 GMT</pubDate>
            <atom:updated>2025-09-08T16:47:57.248Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Learn the Best Frontend Optimization Techniques</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oJsnWAuAGq6Ln3qZbgubKA.png" /></figure><p>Are you one of those frontend devs secretly sweating, thinking AI will replace you any day now?</p><p>Well, let me break it to you - there <em>is</em> a difference between AI-generated code and a real developer’s code. Sure, AI can help you center your divs, generate components, and write decent logic (but <em>only</em> if your prompt game is strong 😂). Otherwise, you’ll end up with a “LoginForm” that books your next vacation and orders a pizza on click.</p><p>But let’s be real - beyond UI and component generation, the real heavy lifting of performance monitoring, optimization, and testing? That still needs a skilled developer with some grey matter and a lot of patience.</p><h4>So who am I to talk?</h4><p>I’ve been working professionally as a Frontend Engineer for………………just one year. Yeah, not exactly a decade of sage wisdom - but in tech years? That’s practically senior citizen status. 👾</p><p>For the past month, I’ve been deep-diving into the world of frontend optimisation through Reddit, YouTube and multiple Medium blogs (yes, just like this one - Hi 👋)</p><p>And guess what? <strong>Frontend optimization is way more than just lazy-loading an image or splitting components.</strong></p><p>I’ll be sharing practical tips, techniques, and real-world implementation strategies that every frontend developer should know (and your Lighthouse score will thank you for it). 🚀</p><h4>1. You should know where your project is heading towards</h4><p>You must have heard from your friends working in big tech giants, that before proceeding to implementation, the whole team sits down to discuss every possible edge case, and only then do they decide on the perfect architecture.</p><p>Similarly, for any developer, the very first step is to actually understand the project. Not just what it does today, but also what it <em>might</em> need to do in the future. That way, you can set up your architecture to grow with it, instead of collapsing like a Jenga tower.</p><p>Why architecture step is even necessary? 🤔</p><p>Imagine you’re building a house brick by brick without a proper blueprint. At the end you realise you’ve ended up making a maze, and now going to washroom from your room will become a quest for you 😂</p><p>Something similar happened with me in the company I’m currently working at. Back then, I had no clue about “architecture,” and we weren’t even sure what features would eventually get injected into the project. The result? The project now runs like it’s on life support. 😭 (Don’t worry, I’m rebuilding a fresh version from scratch - consider it the sequel nobody asked for).</p><p>But what does “deciding the architecture” even mean?</p><ul><li>Choosing which framework/language is the best fit for your project.</li><li>Avoiding “globalized” components that are so over-engineered they turn into tangled spaghetti. Months later, adding one small line of text can spark World War III.</li><li>If the project is massive, with multiple services/features, you might want to consider a micro-frontend architecture.</li><li>And of course… there’s way more. Just Google it (I’m too lazy to write the entire syllabus here 🙂)</li></ul><h4>2. Bundle size</h4><p>Monitoring your bundle size is one of the most important tasks for any frontend dev. In today’s world, where human attention spans are officially shorter than a goldfish’s, every company expects their product to load in milliseconds (yes, milliseconds, because apparently users think your app should teleport itself into their browser 🤌🏻 ).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*43I8mTC3UqOvrQAlkIKkmQ.png" /></figure><p>Take a look at the image above - the main files weigh around <strong>1300 KB</strong>. That makes the page load in about <strong>4–5 seconds</strong>, which means the user is staring at a blank white screen that entire time. And let’s be honest - nothing screams “professional product” like a shiny, white rectangle. 🙃</p><p>Now, bundle size only covers the browser’s initial code compilation. So based on our example, that’s 4–5 seconds gone already. But wait, once that main file is done compiling, your app might start calling APIs….each taking another 3–4 seconds. Add it up, and your user is sitting there for nearly <strong>10 seconds</strong> like a frozen statue.</p><p>Let me tell you honestly: N<strong>o user waits after 3 seconds.</strong><br>Sure, 10 seconds doesn’t sound like much in real life - you’ve probably waited longer for Maggi to cook - but in frontend time, it’s an eternity. And while your app struggles, that poor Wi-Fi provider is getting cursed by users for “slow internet,” completely unaware that your code is the actual villain. 😭 Poor Wi-Fi guy.</p><p>So how can you reduce your bundle size then?</p><ul><li>Use dynamic importing for heavy components. Let the lighter stuff load first instead of doing an “all or nothing” dump.</li><li>For the first interaction, call only the APIs that actually matter. No need to pull an “Avengers Assemble” and summon every single service at once. 💪🏻</li><li>Make sure your bundler (Webpack, Rollup, Vite) is actually removing unused code. And, only import what you need -</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*yjSmSvLluQbG2DzqSkJKmA.png" /></figure><ul><li>Remove unused dependencies and files. Better yet, run a bundle analyzer (webpack-bundle-analyzer) and expose the real culprits bloating your bundle.</li><li>Use tools like <strong>Terser, UglifyJS, or esbuild</strong> to trim your JavaScript into a lean, digestible package.</li></ul><h4>3. Caching &amp; CDN</h4><p>If there’s one thing that travels faster than light, it’s not your code - it’s your neighbour’s WhatsApp gossip. You bring the girl to your house and within five minutes, three different family groups already know that they’ll soon be becoming aunt and uncle 😂</p><p>That’s basically what caching and CDNs are supposed to do for your app, spread your files so fast that no user has to sit around waiting for your homepage.</p><p>Caching makes sure users don’t re-download the same JavaScript, CSS, and images every time they revisit your app. CDNs (Content Delivery Networks) make sure those files live closer to the user - so someone in Delhi isn’t forced to fetch your CSS file from a server chilling in New York 🥲</p><p><strong>BUT. BUT. BUT.</strong><br>If you don’t set caching up properly, your app can either be too slow…or worse, stuck serving users an old version even after you fixed all your bugs. (Imagine deploying a bug fix, but your users still see old errors from last week 🥲)</p><p>Things to keep in mind while implementing caching &amp; CDN:</p><ul><li>For files that do change (like main.js), use versioning or hashing in filenames so browsers know when to fetch the new one.</li><li>If your app feels slower after an update, chances are users are still loading your old bundle.</li><li>Serve static assets (images, CSS, JS) through a CDN close to your users. CDNs are like delivery boys: why would you order chai from New York if there’s a tapri next door?</li><li>Split “vendor” code (React, Vue, libraries) from “app” code. Vendor files don’t change often, so browsers can keep them cached for longer.</li><li>Use <strong>Lighthouse</strong> to see if caching is working as expected.</li></ul><h4>4. Things to be considerate about 🫠</h4><p>I wanted to write more, but it’s 2:00 AM - which means the kid who brought the girl home needs to sleep 😴. You’re smart enough to write another prompt to ChatGPT to explain more (the same way you do with your code).</p><p>But seriously, I’d love to hear some more optimization tricks that I should be considering - if you actually went and researched more about it 🥰</p><h4>Conclusion</h4><p>So, I hope by now you’ve realized there’s still <em>a lot</em> to explore and work on in your frontend journey.</p><p>Just knowing these concepts doesn’t mean you can start stuffing a few extra lines into your AI prompt and — poof — your app is magically optimized 😂</p><p>To become a truly skilled developer, it’s essential to understand how things actually work under the hood. And mastering you frontend skills to the fullest will of course make you irreplaceable 😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf55680cf4c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How server actually works?]]></title>
            <link>https://medium.com/@adiii11/how-server-actually-works-7fcce6b870bc?source=rss-80e62d7a00a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7fcce6b870bc</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[servers]]></category>
            <dc:creator><![CDATA[Aditya Singh]]></dc:creator>
            <pubDate>Mon, 02 Jun 2025 13:14:00 GMT</pubDate>
            <atom:updated>2025-06-02T13:14:00.373Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4jfeJxINsMcrZZGGJNfGCQ.png" /><figcaption>Used “GPT-4o” to generate this image</figcaption></figure><blockquote>Ever wondered how your favorite apps stay online 24/7? this is a beginner’s look of NGINX.</blockquote><h4>A quick look into my journey as a professional in tech</h4><p>So, I’m currently in the pre-final year of my graduation and working as a Frontend Engineer Intern at a startup called “<a href="http://bynd.ai/">Bynd AI</a>”<strong>.</strong> Honestly, I’m not sure if it’s just the early spark of my career, but every single day feels exciting. There’s something incredibly fulfilling about going to the office, sitting down with a bunch of brilliant people, solving real problems, and slowly peeling back the layers of how the apps we use every day <em>actually</em> work behind the scenes.</p><p>And here’s the funny side effect: now, whenever I use any application — be it a food delivery app or a payment portal — my brain doesn’t just <em>use</em> it like a normal person. Nope. I immediately pop open the <strong>Network</strong> tab, tracing requests, checking response times, and thinking, <em>“Hmm… what API are they hitting here?”</em> 😂<br>It’s like I’ve unlocked a secret tech x-ray vision. And let me tell you — it’s oddly fun.</p><p>I used to scroll Instagram to unwind. Now I inspect it. 😅</p><h4>Why Am I Writing This Blog?</h4><p>Usually, I write blogs just so I can revisit them later and revise the concepts in <em>my own language</em> — basically, future-me reads past-me’s notes like a personal cheat sheet. But this time, it’s different.</p><p>I’ve met a lot of juniors at college (and honestly, my past self too) who often stare at a terminal error and wonder, <em>“Wait… what does ‘crashing’ even mean? Did I break the internet? Is this something only senior devs can fix?”</em></p><p><strong>It’s not. But it does feel like that at first.</strong></p><p>To be honest, I’ve been deep into frontend for the past year — CSS battles, pixel-perfect designs, and way too many console.logs. But now, I feel it’s time to level up. So when I started learning about NGINX and how to <em>actually</em> set things up (after googling “how to NGINX like a pro” more times than I’d like to admit), I realized something: <strong>this stuff sounds scarier than it actually is.</strong></p><p>And that’s exactly why I’m writing this blog — to break down these “big tech things” into simple language. So the next time you hear about servers or crashes, you won’t panic. You’ll say, <em>“I read a blog about this 😎”</em></p><h4>Lets understand server crash with a real life example</h4><p>Imagine it’s New Year’s Eve. You’re all dressed up, ready to bless Instagram with your “Happy New Year” post. But the post is stuck at “Posting…”. You start panicking — <em>“Is it my Wi-Fi? My data?”</em></p><p>And then your non-tech friend, with the confidence of someone who once fixed a remote by slapping it, casually says:<br><strong>“Dude, maybe just buy a new phone.”</strong> 😭<br>Like yes, clearly my phone couldn’t handle the heat of posting a simple selfie.</p><p>Meanwhile, millions of people around the world are doing <strong>the exact same thing</strong> — trying to upload photos, send DMs, and refresh their feed at the exact same moment.</p><p>So, do the smart engineers at Meta fix these moments by slapping their systems? Of course not 😂 But here’s what they actually do —</p><ul><li><strong>Load Balancing</strong>: Think of it like redirecting traffic. Instead of making one server suffer alone, requests are evenly spread across multiple servers so none of them gets overwhelmed.</li><li><strong>Auto-Scaling</strong>: The moment Instagram detects traffic going up like crazy, it spins up <strong>more servers automatically</strong> in the cloud — kind of like calling in reinforcements. More users = more servers = less crying.</li><li><strong>Caching</strong>: Static data (like your favourite celebrity’s post) is temporarily saved closer to the user, so it doesn’t have to be fetched from scratch every single time.</li><li><strong>CDNs (Content Delivery Networks)</strong>: These help serve content from the nearest geographical server. So if 10 million people in India are watching Netflix, the data doesn’t have to come all the way from California — it’s already hanging out on a nearby CDN.</li></ul><p>And yes, <strong>NGINX</strong> plays a massive role in all this. It helps handle incoming traffic smartly and redirects it without overloading any one system. It’s like the cool bouncer outside a club, letting people in smoothly without starting a riot.</p><p>So next time your app freezes and your friend hits you with that same old lame joke — “Just buy a new phone”, then make sure to tell him what’s actually happening in the background.</p><h4>Let’s Dive Deep into How NGINX Works</h4><p>Ever wondered who’s behind the scenes making sure your cat video loads faster than your exam results?</p><p>Its <strong>NGNIX</strong> — one of the most powerful and reliable tools keeping today’s web running smoothly. It silently handles millions of requests, ensuring that websites stay fast, responsive, and available — even under pressure.</p><p><strong>NGINX has three main features: Load Balancing, Caching, and Security.</strong> For any platform, these three are some of the most important aspects to take care of, and it makes configuring them surprisingly simple. Let’s undetstand each feature one by one -</p><ol><li><strong>Load Balancing</strong></li></ol><p>Load balancing is like having a smart traffic controller for your website. Imagine you have a popular restaurant with multiple kitchens. When customers place orders, you need someone to decide which kitchen should prepare each order so that no single kitchen gets overwhelmed while others sit idle. That’s exactly what load balancing does for web servers.</p><p>When a user requests data from a website, the request first goes to a <strong>proxy server</strong> (in our case, NGINX). This proxy server acts as an intelligent middleman that determines which backend server should handle the request. Instead of all requests hitting one server and potentially crashing it, the load balancer distributes the work evenly across multiple servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UAk5bhHqo2ZAJBKktywoow.png" /></figure><p>NGINX offers several methods to distribute traffic among your servers:</p><ul><li><strong>Round Robin Method (Default): </strong>This is the simplest method where NGINX distributes requests in a rotating fashion. If you have 3 servers, the first request goes to Server 1, second to Server 2, third to Server 3, and the fourth request goes back to Server 1.</li><li><strong>Least Connections Method: </strong>This smarter approach sends new requests to the server that currently has the fewest active connections. It’s like choosing the shortest queue at a grocery store. It is perfect when your requests take varying amounts of time to process. Some might finish quickly while others take longer.</li><li><strong>IP Hash Method:</strong> This method uses the client’s IP address to determine which server handles their requests. The same user will always be directed to the same server. It is useful when you want to keep the user logged in to the same server.</li></ul><p>The best thing about NGINX is, it can also monitor your servers’ health. If a server becomes unresponsive, NGINX automatically stops sending requests to it until it recovers.</p><p>2. <strong>Caching</strong></p><p>Caching is like having a smart storage system that remembers frequently requested information. Imagine you’re a librarian, and students keep asking for the same popular book every day. Instead of walking to the storage room each time, you keep a copy of that book right at your desk for quick access. That’s exactly what caching does for websites!</p><p>When NGINX caches content, it stores copies of frequently requested data closer to users, dramatically reducing response times and server load.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vf65evFAjph-eGRC_ZbQgw.png" /></figure><p>The image shows the caching process works in two distinct phases. When multiple users request the same content, NGINX receives all these requests but has no cached data available since it’s the first time this content is being requested. NGINX then forwards the request to a backend server (using methods like least connections), which processes the request by fetching data from the database, sends the response back to NGINX, and NGINX intelligently stores a copy of this response in its cache before delivering it to all the users.</p><p>For <strong>subsequent requests (cache hit)</strong>, when new users request the same data, NGINX checks its local cache first instead of forwarding to the backend server, finds the data in its cache, and instantly serves the cached response directly to users without any involvement from the backend servers or database, dramatically reducing response time and server load.</p><p>3. <strong>Security</strong></p><p>NGINX security is like having a bouncer named Bob at your exclusive nightclub. Bob doesn’t just check IDs — he makes everyone whisper their secrets in a secret code language that only he understands (encryption), blindfolds visitors so they can’t see where the VIP rooms are located (hiding server infrastructure), and has an ability to spot troublemakers (hackers) from a mile away, immediately tossing them out before they can cause a scene.</p><p>NGINX acts as your digital Bob, standing between the wild internet and your servers, making sure only the good guys get in while keeping all the hackers wondering why they can’t find your actual servers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*95tseQ2trNenoIEViumRlQ.png" /></figure><p><strong>Security Flow:</strong> When a user makes a request to your website, NGINX creates multiple layers of security protection. The user connects to the proxy server (which is publicly accessible), but all communication is encrypted using <strong>SSL/TLS encryption</strong>. Even if a hacker intercepts this communication, they cannot read the encrypted data. Meanwhile, your actual application servers remain completely hidden in a private network, invisible and inaccessible to external threats.</p><p>NGINX acts as the only bridge between the public internet and your private infrastructure, carefully filtering and validating every request before it reaches your backend servers.</p><h4>Compression</h4><p>NGINX compression is like having a master magician who can shrink an entire elephant to fit in your pocket.</p><p>Like Netflix has a magical shrinking machine that squeezes a 4K movie from the size of a watermelon down to the size of a grape, sends it through the internet at lightning speed — it magically expands back to full size on your screen without losing any of the Demogorgon’s terrifying details. 👾</p><p><strong>Types of compressions -</strong></p><ul><li><strong>Gzip Compression:</strong> This is like Netflix’s standard compression — works great for most content and makes everything about 70% smaller.</li><li><strong>Brotli Compression: </strong>Brotli is like gzip’s younger sibling who went to college and came back showing off. It can compress files up to 20% smaller than gzip.</li></ul><p>So the next time your movie starts doing the digital equivalent of stuttering, just know that somewhere out there, a lonely proxy server is having an existential crisis about data compression. It’s not you, it’s literally the machine having a breakdown about squishing pixels. 😂</p><h4>Conclusion</h4><p>I hope everything makes sense now ☕️ You don’t have to worry like I did about how everything works. Now you’re probably thinking ‘huh, that was nothing’ — because that was exactly my response too.</p><p>It does feel great to learn new things, but the real learning starts when you implement them. Let me know if you’ve worked with NGINX before, or if you’re someone like me who has recently started their journey into this wonderland of digital chaos 😂 do let me know in comment…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7fcce6b870bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[All about “Hooks” in React JS]]></title>
            <link>https://medium.com/@adiii11/all-about-hooks-in-react-js-9ac1c48a166d?source=rss-80e62d7a00a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ac1c48a166d</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Aditya Singh]]></dc:creator>
            <pubDate>Wed, 25 Sep 2024 13:32:59 GMT</pubDate>
            <atom:updated>2024-09-25T13:32:59.770Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>Ever wondered how professional programmers write code that runs so quickly and looks incredibly optimized?</em></blockquote><p>Hooks in React JS revolutionize how developers approach component logic, bringing fresh solutions to common web development problems. Hooks are capable of nifty functions allowing a programmer to tap into React’s state management and life cycles with fewer words of code than class components, yielding cleaner, much more readable code. This allows for reusing the stateful logic between components, improved organization with reduced redundancy, and improved maintainability of the projects.</p><p>Hooks make it easier for developers to break complex components down into smaller functions that are more focused in their efforts, thus enhancing both modularity and testability. Not only does this elegant abstraction make management of the component’s state easier, but it also encourages best practices in the development of React application teams more feasible to collaborate in producing scalable and efficient applications.</p><figure><img alt="Types of Hooks" src="https://cdn-images-1.medium.com/max/1024/1*mRVpPbVP6AXZwHXvruLkyg.png" /></figure><p>To use a hook in your code, you must first import it from the react library at the top of your code file, like this -</p><pre>import {useState, useEffect, useRef} from &quot;react&quot;</pre><h3>1. useState</h3><p>Imagine you have a box, and inside that box, you can put anything you want — like a number, word, or picture. Now, with the help of the useState hook, you can open that box and change what’s inside it!!</p><pre>import {useState} from &quot;react&quot;<br><br>const functionName(){<br><br>//declaring a state<br>const[count, setCount] = useState(0);<br><br>//Using &quot;setCount&quot; we&#39;ll be changing the state value of the count<br><br>return (<br>    &lt;div&gt;<br>      &lt;p&gt;You clicked {count} times&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;<br>        Click me<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In the above code, we have created a state called — “count”, and set its value to 0 in the default case. As the user clicks the button, “setCount” will become active and will increment the state value by 1.</p><h3>2. useHook</h3><p>Let’s say you have a component that displays the current time. Every second, the time changes, so you need a way to update the component to show the new time. That’s where the useEffect hook comes in! You can use it to say, &quot;Hey, every time the second changes, I want you to update the time in my component.&quot;</p><p>The useEffect hook is also really useful for things like fetching data from the internet, setting up event listeners, or cleaning up any resources your component uses. Basically, anytime your component needs to do something that involves something happening over time, the useEffect hook is probably the tool you want to use.</p><pre>import React, { useState, useEffect } from &#39;react&#39;;<br><br>function Counter() {<br>  const [count, setCount] = useState(0);<br><br>  useEffect(() =&gt; {<br>    // This function will be called whenever the count changes<br>    console.log(`The count is now ${count}`);<br>  }, [count]);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;You clicked {count} times&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;<br>        Click me<br>      &lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>So, in the above code, we have passed the “count” as a dependency in useEffect. This means that when the state of the count changes, the useEffect will also be triggered.</p><p><strong>The primary use cases for </strong><strong>useEffect include:</strong></p><ul><li><strong>Data Fetching</strong>: Fetching data from an API and updating the component’s state when the data is received.</li><li><strong>Manual DOM Mutations</strong>: Directly manipulating the DOM, such as setting up event listeners or timers.</li><li><strong>Subscriptions</strong>: Setting up and tearing down subscriptions, such as WebSocket connections or event listeners.</li><li><strong>Performance Optimizations</strong>: Memoizing expensive calculations or skipping unnecessary re-renders.</li></ul><h3>3. useContext</h3><p>Imagine you have a bunch of friends, and each of your friends has their own favorite color. You want to be able to keep track of what color each of your friends likes, so you can remember it.</p><p>The useContext hook is like a special way to keep track of all your friends&#39; favorite colors in one place. It&#39;s like a big box where you can put all the information about your friends&#39; color preferences.</p><pre>//app.jsx file<br><br>import React, { createContext, useState} from &#39;react&#39;;<br><br>// This creates the &quot;ColorContext&quot; - the big box where we&#39;ll put all the color information<br>const ColorContext = createContext();<br><br>function App() {<br>  // We use the useState hook to store the color preferences<br>  const [colorPreferences, setColorPreferences] = useState({<br>    alice: &#39;blue&#39;,<br>    bob: &#39;red&#39;,<br>    charlie: &#39;green&#39;<br>  });<br><br>  return (<br>    // We &quot;provide&quot; the color information to the rest of the app using the ColorContext.Provider<br>    &lt;ColorContext.Provider value={colorPreferences}&gt;<br>      &lt;MyComponent /&gt;<br>    &lt;/ColorContext.Provider&gt;<br>  );<br>}</pre><pre>//component.jsx file<br><br>import React, { useState, useContext } from &#39;react&#39;;<br><br>function MyComponent() {<br>  // We use the useContext hook to &quot;consume&quot; the color information from the ColorContext<br>  const colors = useContext(ColorContext);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;Alice&#39;s favorite color is {colors.alice}&lt;/p&gt;<br>      &lt;p&gt;Bob&#39;s favorite color is {colors.bob}&lt;/p&gt;<br>      &lt;p&gt;Charlie&#39;s favorite color is {colors.charlie}&lt;/p&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>In this example, the useContext hook allows the Component to access the color preferences that were stored in the ColorContext. This way, the component doesn&#39;t have to worry about where the color information is coming from - it can just use the useContext hook to get what it needs.</p><p>The main benefit of using useContext is that it can help simplify the props drilling problem, where you have to pass props down through many levels of components just to get data to the components that need it. By using context, you can make that data available globally, and components can simply consume the data they need using the useContext hook.</p><p>Overall, useContext is a powerful tool for managing state and data flow in React applications, especially as they grow in complexity.</p><h3>4. useCallback</h3><p>Imagine you have a special toy that can do tricks. Every time you want the toy to do a trick, you have to tell it exactly what to do. But sometimes, even if you’re asking for the same trick, the toy thinks it’s a new trick and gets confused.</p><p>The useCallback hook is like a magic way to help your toy remember the tricks you&#39;ve already taught it. It&#39;s as if you could put a sticker on the toy that says &quot;Remember this trick!&quot; So when you ask for the same trick again, the toy knows it&#39;s not a new trick and performs it perfectly without getting confused.</p><pre>import React, { useState, useCallback } from &#39;react&#39;;<br><br>function TodoList() {<br>  const [todos, setTodos] = useState([]);<br>  const [count, setCount] = useState(0);<br><br>  const addTodo = useCallback(() =&gt; {<br>    setTodos((t) =&gt; [...t, &quot;New Todo&quot;]);<br>  }, []);<br><br>  const increment = useCallback(() =&gt; {<br>    setCount((c) =&gt; c + 1);<br>  }, []);<br><br>  return (<br>    &lt;&gt;<br>      &lt;div&gt;<br>        Count: {count}<br>        &lt;button onClick={increment}&gt;+&lt;/button&gt;<br>      &lt;/div&gt;<br>      &lt;h3&gt;Todos&lt;/h3&gt;<br>      {todos.map((todo, index) =&gt; (<br>        &lt;p key={index}&gt;{todo}&lt;/p&gt;<br>      ))}<br>      &lt;button onClick={addTodo}&gt;Add Todo&lt;/button&gt;<br>    &lt;/&gt;<br>  );<br>}</pre><p>The useCallback hook is used to memoize functions in React. It&#39;s particularly useful when passing callbacks to optimized child components that rely on reference equality to prevent unnecessary renders.</p><p>In the example above, we’re using useCallback for two functions: addTodo and increment.</p><ol><li>addTodo is memoized with an empty dependency array []. This means the function will be created once when the component mounts and will remain the same across re-renders. It&#39;s safe to do this because addTodo doesn&#39;t depend on any props or state.</li><li>increment is also memoized with an empty dependency array. Like addTodo, it doesn&#39;t depend on any external values, so it can be safely memoized without dependencies.</li></ol><p>The main benefits of using useCallback are:</p><ol><li><strong>Performance optimization</strong>: It can prevent unnecessary re-renders in child components that receive these callbacks as props, especially when used in conjunction with React.memo.</li><li><strong>Referential equality</strong>: It ensures that the function reference remains the same between renders if the dependencies haven’t changed. This is crucial for hooks like useEffect that compare dependencies by reference.</li></ol><h3>5. useMemo</h3><p>Imagine you have a big coloring book, and you love to color in a specific picture that takes a long time to complete. Every time you open the book, you don’t want to color the same picture all over again if it hasn’t changed.</p><p>useMemo is like a magical sticker you put on that picture. It says, &quot;Hey, remember this colored picture!&quot; So, when you open the book again, you only need to color the picture if something about it has changed. Otherwise, you can enjoy the picture you already colored without doing all the work again.</p><pre>import React, { useState, useMemo } from &#39;react&#39;;<br><br>function ExpensiveCalculation({ numbers }) {<br>  const [count, setCount] = useState(0);<br><br>  const expensiveResult = useMemo(() =&gt; {<br>    console.log(&#39;Calculating...&#39;);<br>    return numbers.reduce((total, num) =&gt; total + num, 0);<br>  }, [numbers]);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;p&gt;Sum: {expensiveResult}&lt;/p&gt;<br>      &lt;p&gt;Count: {count}&lt;/p&gt;<br>      &lt;button onClick={() =&gt; setCount(count + 1)}&gt;Increment&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>useMemo is a React hook used for memoizing expensive computations. It takes two arguments:</p><ol><li>A function that performs the computation</li><li>An array of dependencies</li></ol><p>The hook will only recompute the memoized value when one of the dependencies has changed. This optimization helps to avoid expensive calculations on every render.</p><p>In the example above:</p><ol><li>We have an expensive calculation (summing up all numbers in an array).</li><li>We wrap this calculation in useMemo.</li><li>We provide [numbers] as the dependency array.</li></ol><p>This means:</p><ul><li>The sum will only be recalculated if the numbers prop changes.</li><li>If count changes (when the button is clicked), the component will re-render, but the expensive calculation won&#39;t run again.</li></ul><p>While useMemo can improve performance, it also adds complexity and uses additional memory. It should be used judiciously</p><h3>6. useRef and Custom Hooks</h3><p>useRef is a React hook that returns a mutable ref object whose .current property is initialized to the passed argument. It&#39;s commonly used to access DOM elements directly, store mutable values that don&#39;t cause re-renders when they change, or to persist values across renders without triggering a re-render. Unlike state, updating a ref doesn&#39;t cause a component to re-render. Custom hooks, on the other hand, are JavaScript functions that start with &quot;use&quot; and may call other hooks. They allow you to extract component logic into reusable functions, enabling you to share stateful logic between components without changing their structure. Custom hooks can encapsulate complex logic, state management, and side effects, making your components cleaner and more modular. They follow the same rules as React&#39;s built-in hooks and can be composed to create more complex behaviors.</p><h3>Conclusion -</h3><p>Learning React hooks is like unlocking a superpower for frontend developers! These amazing tools help you create more efficient, cleaner, and easier-to-maintain code. With hooks, you can say goodbye to complex class components and hello to simpler, more intuitive functional components.</p><p>Why start practicing hooks today? Well, they’re not just a trend — they’re the future of React development. By mastering hooks, you’ll be able to:</p><ol><li>Write more concise and readable code</li><li>Reuse stateful logic across components without complex patterns</li><li>Manage state and side effects more efficiently</li><li>Create powerful custom hooks to solve specific problems in your projects</li></ol><p>Plus, many modern React libraries and frameworks are built with hooks in mind. By getting comfortable with hooks now, you’ll be well-prepared for the exciting new tools and techniques coming to the React ecosystem.</p><p>Remember, like any skill, getting good with hooks takes practice. But don’t worry — every little bit of practice counts! Start small, experiment with different hooks, and before you know it, you’ll be hooking up amazing React applications like a pro.</p><p>Aditya Singh</p><p>adityasinghwork11@gmail.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ac1c48a166d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>