<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ CDN - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ CDN - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 23 Aug 2026 21:53:42 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/cdn/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ What to Do if Your Site Is About to Hit Vercel's Free Image Optimization Cap ]]>
                </title>
                <description>
                    <![CDATA[ I maintain my own website, and every now and then I upgrade the site to a new version. And I frequently experiment with different technologies and architectures while doing so. Recently, I faced an is ]]>
                </description>
                <link>https://www.freecodecamp.org/news/what-to-do-if-your-site-is-about-to-hit-vercels-free-image-optimization-cap/</link>
                <guid isPermaLink="false">6a848de33638e739c70ebce3</guid>
                
                    <category>
                        <![CDATA[ Next.js ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Vercel ]]>
                    </category>
                
                    <category>
                        <![CDATA[ image optimization  ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CDN ]]>
                    </category>
                
                    <category>
                        <![CDATA[ cloudflare ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Md. Fahim Bin Amin ]]>
                </dc:creator>
                <pubDate>Tue, 18 Aug 2026 16:52:51 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/uploads/covers/5e1e335a7a1d3fcc59028c64/58b79fa2-e0a0-4172-b07f-e3446413eca8.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>I maintain my own website, and every now and then I upgrade the site to a new version. And I frequently experiment with different technologies and architectures while doing so.</p>
<p>Recently, I faced an issue where Vercel was giving me a warning that I was almost reaching my free tier limit on "Image Optimization - Transformation". After a few trials and errors, I managed to fix that so that it doesn't exceed my free tier unnecessarily.</p>
<p>In this article, I'll explain what the issues were, how I pinpointed the exact cause, and what options I had for resolving them. I'll also walk you through the approach I ultimately chose and how I managed to fix the problem.</p>
<h3 id="heading-so-what-was-the-problem">So What Was the Problem?</h3>
<p>My current website is running on version 5 (Year 2026), which uses a CDN from Cloudflare R2 Object Storage. It also has massive SEO optimization for both web search and AI search.</p>
<p>You can check out the website directly here: <a href="https://fahimbinamin.com">fahimbinamin.com</a>. I'm not sure which version you'll be able to see in the domain when you're visiting the website, but it'll always be the latest version.</p>
<img src="https://cdn.hashnode.com/uploads/covers/60752ce9308cd51e1477fe19/6a478190-2df6-4138-b740-e0331833c0db.png" alt="Fahim's Website (5th version)" style="display:block;margin:0 auto" width="600" height="400" loading="lazy">

<p>As version 5 of my website is a multi-page website, I tried to include everything about me under one platform. I have a lot of writing published in multiple places, and I wanted to add all of the articles under the same platform. But I also wanted to make sure that their canonical URLs worked well. This would help the AI crawler/bot understand the original published URL/source. So I incorporated this feature in the 5th version of my website.</p>
<p>This website uses Next.js and Next's image optimization protocol properly. Currently, the codebase is closed source and you won't be able to access it anywhere. But I've shared a screenshot so that you can have a glimpse of how it looks now.</p>
<img src="https://cdn.hashnode.com/uploads/covers/60752ce9308cd51e1477fe19/5fbedbc8-a5a1-4d84-8eb2-90efc8b81aeb.png" alt="Fahim's website's (5th version) codebase on GitHub (Closed Source)" style="display:block;margin:0 auto" width="600" height="400" loading="lazy">

<p>Anyway, to save money, I like to utilize free resources as effectively as possible. For the CDN, I'm using Cloudflare with R2 object storage. All the media you see on my website (images, PDFs, and so on) comes from Cloudflare R2 object storage. It's running via Vercel.</p>
<p>Everything was going smoothly until yesterday, when I noticed an email from Vercel stating that I was approaching my free tier limit for image optimization.</p>
<img src="https://cdn.hashnode.com/uploads/covers/60752ce9308cd51e1477fe19/c777113f-a8a5-41b5-a696-82f7d8ab2e37.png" alt="Warning about Image Optimization" style="display:block;margin:0 auto" width="600" height="400" loading="lazy">

<p>I opened the usage panel expecting to see my own project images: profile photos, project screenshots, and gallery frames. Instead, almost every source image listed was hosted on <a href="http://freecodecamp.org"><code>freecodecamp.org</code></a>.</p>
<p>This was confusing for a few seconds because I don't host my images on freeCodeCamp. Then I remembered that I actually link to them!</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<p>I've organized the entire article with sections that can help you jump around if you want or need to read any specific section separately.</p>
<ul>
<li><p><a href="#heading-where-these-images-actually-come-from">Where These Images Actually Come From</a></p>
</li>
<li><p><a href="#heading-confirming-the-scope">Confirming the Scope</a></p>
</li>
<li><p><a href="#heading-two-ways-to-fix-this-issue">Two Ways to Fix This Issue</a></p>
</li>
<li><p><a href="#heading-which-solution-i-chose">Which Solution I Chose</a></p>
</li>
<li><p><a href="#heading-doing-the-migration">Doing the Migration</a></p>
</li>
<li><p><a href="#heading-why-this-is-the-better-fix-long-term">Why This Is the Better Fix Long-Term</a></p>
</li>
<li><p><a href="#heading-what-i-will-do-differently-next-time">What I Will Do Differently Next Time</a></p>
</li>
<li><p><a href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-where-these-images-actually-come-from">Where These Images Actually Come From</h2>
<p>I have cross-posted a lot of my writing to freeCodeCamp over the years. When I backfilled my articles into this site's blog archive, I kept the article bodies intact, including the <code>&lt;img&gt;</code> tags pointing at freeCodeCamp's and Hashnode's CDNs (as those were the places where the screenshots had always lived).</p>
<p>The blog renderer wraps every inline image in a <code>BlogImage</code> component:</p>
<pre><code class="language-javascript">import Image from "next/image";
 
export default function BlogImage({ src, alt, caption }) {
  return (
    &lt;figure&gt;
      &lt;Image src={src} alt={alt} fill sizes="(max-width: 768px) 100vw, 768px" /&gt;
      &lt;figcaption&gt;{caption}&lt;/figcaption&gt;
    &lt;/figure&gt;
  );
}
</code></pre>
<p><code>next/image</code> actually doesn't care whether the <code>src</code> points at your own domain or someone else's. As long as the host is listed in <code>images.remotePatterns</code> in <code>next.config.ts</code>, Next.js will run it through Vercel's Image Optimization pipeline in this step, including fetching the original, resizing it for every breakpoint, re-encoding to AVIF/WebP, and caching the result.</p>
<p>I had added <code>cdn-media-0.freecodecamp.org</code>, <code>www.freecodecamp.org</code>, and <code>cdn.hashnode.com</code> to that allowlist months ago in two separate commits. I did that specifically so those backfilled images would render instead of breaking.</p>
<p>That actually worked for me in this case. But it also meant that every one of those images (and every responsive size Next.js generated from each one) counted against my Vercel account's free-tier Image Optimization quota. I don't want my quota to be spent carelessly, since it resets monthly and I don't control how many times a crawler or a page load re-triggers a size variant.</p>
<h2 id="heading-confirming-the-scope">Confirming the Scope</h2>
<p>Before fixing anything, I wanted real numbers instead of a guess. I grepped every post in <code>content/posts/*.mdx</code> for <code>src="..."</code> attributes pointing at the three external hosts:</p>
<pre><code class="language-javascript">src="(https://(?:cdn-media-0\.freecodecamp\.org|www\.freecodecamp\.org|cdn\.hashnode\.com)[^"]*)"
</code></pre>
<p>That turned up 691 image references across 33 posts: old screenshots from tutorials going back to 2021, everything from disk-partitioning walkthroughs to CUDA setup guides. All of it was being optimized on someone else's dime (mine) instead of being cached once and served flat. That's what was causing the issue earlier.</p>
<p>When I was looking for solutions, I found two ways that could instantly help me fix the issue quickly.</p>
<h2 id="heading-two-ways-to-fix-this-issue">Two Ways to Fix This Issue</h2>
<p><strong>Option 1: Stop optimizing them.</strong> Pass <code>unoptimized</code> to <code>next/image</code> for any source that isn't my own CDN. Vercel stops touching those requests entirely.</p>
<p>In that case, the browser fetches the image straight from freeCodeCamp, and there's no resizing or AVIF conversion, and zero quota impact. This means that it will be just a small diff that can be done in minutes.</p>
<p><strong>Option 2: Own the images.</strong> Download all 691, re-host them on the Cloudflare R2 bucket I already use for every other image on the site, rewrite the <code>src</code> attributes to point at <code>cdn.fahimbinamin.com</code>, and drop the three external hosts from <code>remotePatterns</code> entirely.</p>
<h2 id="heading-which-solution-i-chose">Which Solution I Chose</h2>
<p>Option 1 was tempting for how little needed to be touched. But it meant permanently giving up responsive sizing and modern formats for a third of my blog archive, and it left the site depending on freeCodeCamp's CDN staying up and those specific URLs never changing.</p>
<p>Option 2 costs more up front but matches how every other image on the site already works. It also keeps the optimization benefit and removes the external dependency completely. So I went with Option 2.</p>
<h2 id="heading-doing-the-migration">Doing the Migration</h2>
<h3 id="heading-step-1-download-everything">Step 1: Download Everything</h3>
<p>I wrote a small Node script that walked every post, matched the same three-host regex, and pulled down each unique URL:</p>
<pre><code class="language-javascript">const HOST_RE =
  /src="(https:\/\/(?:cdn-media-0\.freecodecamp\.org|www\.freecodecamp\.org|cdn\.hashnode\.com)[^"]*)"/g;
 
// ...for each match, download to downloaded-images/&lt;slug&gt;/&lt;filename&gt;
// and record oldUrl -&gt; "images/writing/&lt;slug&gt;/&lt;filename&gt;" in url-map.json
</code></pre>
<p>Files were organized by post slug specifically to avoid collisions, since a lot of these screenshots share generic names like <code>2022-01-20_18-50.png</code> across completely different tutorials. Lastly, it was a total of 691 downloads with 0 failures, about 105 MB in total.</p>
<h3 id="heading-step-2-upload-to-r2">Step 2: Upload to R2</h3>
<p>I restructured the download folder to mirror the target key prefix (<code>images/writing/&lt;slug&gt;/...</code>) and uploaded it to the bucket using <a href="https://s3browser.com/">CS Browser</a>. R2 exposes an S3-compatible API and a GUI client handles hundreds of nested files more reliably than dragging a folder through the dashboard.</p>
<h3 id="heading-step-3-verify-before-touching-content">Step 3: Verify Before Touching content</h3>
<p>Before rewriting anything, I spot-checked a couple of the newly uploaded URLs:</p>
<pre><code class="language-shell">curl -s -o /dev/null -w "%{http_code}\n" \
  "https://cdn.fahimbinamin.com/images/writing/automount-a-storage-partition-on-startup-in-linux/HDD-Partition.png"
# 200
</code></pre>
<h3 id="heading-step-4-rewrite-the-mdx">Step 4: Rewrite the MDX</h3>
<p>A second script read <code>url-map.json</code> and replaced every matching <code>src="..."</code> in <code>content/posts/*.mdx</code> with the equivalent <code>cdn.fahimbinamin.com</code> URL:</p>
<pre><code class="language-javascript">content = content.replace(HOST_RE, (match, url) =&gt; {
  const entry = urlMap[url];
  if (!entry) return match; // left untouched, logged for review
  return `src="${CDN_BASE}/${entry.cdnPath}"`;
});
</code></pre>
<p>After the testing, I found out that a total of 33 files changed, 692 replacements (one image was referenced twice in the same post), and 0 were left unmapped.</p>
<h3 id="heading-step-5-clean-up-the-config">Step 5: Clean Up the Config</h3>
<p>With no more <code>&lt;Image&gt;</code> references to the external hosts, I removed all three from <code>images.remotePatterns</code> in <code>next.config.ts</code>:</p>
<pre><code class="language-javascript">// Removed, no longer needed
{ protocol: "https", hostname: "cdn.hashnode.com", pathname: "/**" },
{ protocol: "https", hostname: "cdn-media-0.freecodecamp.org", pathname: "/**" },
{ protocol: "https", hostname: "www.freecodecamp.org", pathname: "/**" },
</code></pre>
<p>I ran a full production build afterward. All 43+ blog posts pre-rendered clean, lint passed, and nothing was broken.</p>
<h2 id="heading-why-this-is-the-better-fix-long-term">Why This Is the Better Fix Long-Term</h2>
<p>The quota problem was really a symptom of a smaller mistake: treating a third-party CDN as if it were infrastructure that I controlled. It rendered fine for months, right up until usage crossed a threshold I wasn't watching closely enough.</p>
<p><code>unoptimized</code> would have made the warning go away without addressing the issue. But I would have kept depending on freeCodeCamp's URLs staying valid indefinitely, with no optimization to show for it either.</p>
<p>Self-hosting means that every image on this site now goes through the same pipeline, and uses the cache rules and CDN, regardless of where the content originally lived. I didn't want anything that could silently break because someone else changed a URL structure.</p>
<h2 id="heading-what-i-will-do-differently-next-time">What I Will Do Differently Next Time</h2>
<p>The two <code>remotePatterns</code> entries for freeCodeCamp and Hashnode were each added months apart, each time because a backfilled post's images were broken and adding the host was the fastest fix.</p>
<p>I never asked myself before, "should this actually be hosted here, or should it live on my own CDN from day one?" That question is cheap to ask before backfilling content and expensive to answer after 691 images and 33 posts are already live pointing outward.</p>
<p>I've written that rule down now, so future backfills download and re-host before a single <code>&lt;img&gt;</code> tag ever points off-domain.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>Thank you so much for reading all the way through. I hope that this article will help you if you face the same issue in the future.</p>
<p>To get more content like this, you can follow me on <a href="https://www.linkedin.com/in/fahimfba/">LinkedIn</a> and <a href="https://x.com/Fahim_FBA">X</a>. You can also check <a href="https://www.fahimbinamin.com/">my website</a> and follow me on <a href="https://github.com/FahimFBA">GitHub</a> if you're into open source and development. If you like to watch programming and technology-related videos, then you can <a href="https://www.youtube.com/@FahimAmin">subscribe to my YouTube channel</a> as well.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Use CDNs to Improve Performance in your Front-end Projects ]]>
                </title>
                <description>
                    <![CDATA[ In web development, styling plays a crucial role in the visual presentation of web applications. According to a study by Adobe, 59% of users would choose a beautifully designed website over a “simple and plain” design. So designs that are crafted in ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-cdns-improve-performance-in-front-end-projects/</link>
                <guid isPermaLink="false">670d72a6d4c1491e5ee9df77</guid>
                
                    <category>
                        <![CDATA[ Frontend Development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ CDN ]]>
                    </category>
                
                    <category>
                        <![CDATA[ computer networking ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Timothy Olanrewaju ]]>
                </dc:creator>
                <pubDate>Mon, 14 Oct 2024 19:36:06 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1728820334493/8ef2738f-c2ac-42d3-be3f-5a6a3bddbdbd.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In web development, styling plays a crucial role in the visual presentation of web applications. According to a study by Adobe, 59% of users would choose a beautifully designed website over a “simple and plain” design. So designs that are crafted in a visually appealing way tend to attract users to consume content on a website.</p>
<p>In recent times, there has been a steady rise in styling tools that you can use to elevate the visual appeal of your websites. Such tools include CSS frameworks, animation libraries, icon libraries, and typography libraries. These tools offer customization flexibility, responsiveness, and consistency.</p>
<p>One awesome thing about these styling tools is that they bundle stylistic effects in a file which you can access via a Content Delivery Network (CDN).</p>
<p>In this article, we’ll be looking extensively at CDNs, how they work, their different hosting methods, the differences between them, their pros and cons, and the best use-cases of the methods for your project.</p>
<p>Let's dive straight into it!</p>
<h3 id="heading-what-well-cover">What we’ll cover:</h3>
<ol>
<li><p><a class="post-section-overview" href="#heading-what-is-a-cdn">What is a CDN?</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-how-does-a-cdn-work">How does a CDN work?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-real-world-analogy-to-explain-cdns">Real-world analogy to explain CDNs</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-why-are-cdns-important">Why are CDNs Important?</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-different-ways-to-use-a-cdn">Different Ways to Use a CDN</a></p>
<ul>
<li><p><a class="post-section-overview" href="#heading-remote-hosted-cdn">Remote Hosted CDN</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-locally-hosted-cdn">Locally Hosted CDN</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-hybrid-hosted-cdn">Hybrid Hosted CDN</a></p>
</li>
</ul>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ol>
<h2 id="heading-what-is-a-cdn"><strong>What is a CDN?</strong></h2>
<p>A CDN, or Content Delivery Network, is a system of distributed servers that delivers web content (like images, stylesheets, scripts and other resources) to users, reliably and efficiently.</p>
<h3 id="heading-how-does-a-cdn-work"><strong>How does a CDN work?</strong></h3>
<p>A CDN’s primary function is to cache and serve both static and dynamic web content to users. It achieves this by using the following:</p>
<ul>
<li><p><strong>Origin Server</strong>: This is the main server where all content is originally hosted.</p>
</li>
<li><p><strong>Edge Servers</strong>: These are servers distributed in different geographical locations to serve web content to users closer to them.</p>
</li>
<li><p><strong>Caching</strong>: This is a way of storing content on edge servers to reduce repeated requests to the origin server.</p>
</li>
<li><p><strong>DNS Routing</strong>: This is the mechanism that reroutes users to the nearest edge servers based on their location.</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1728819505243/6389ac39-e1d2-4348-9f97-8ee370eecd7f.png" alt="Diagram showing origin server communicating with different edge servers" class="image--center mx-auto" width="1600" height="900" loading="lazy"></p>
<p>This is what happens when a user clicks on a CDN link:</p>
<ul>
<li><p>If trying to access the resource for the first time, the request hits the origin server.</p>
</li>
<li><p>The origin server sends the resource to the user as a response and also sends a copy to the edge server located geographically closest to the user.</p>
</li>
<li><p>The edge server caches the copy.</p>
</li>
<li><p>When the user wants to access the resources again, the edge server (not the origin server) sends over the cached copy.</p>
</li>
</ul>
<h3 id="heading-real-world-analogy-to-explain-cdns"><strong>Real-World Analogy to Explain CDNs</strong></h3>
<p>To further explain how the CDN works, I’ll give an analogy to make it clearer. Imagine having an account with a bank that has its headquarters in New York (origin server).</p>
<p>You don’t expect customers who live far away from New York to be scampering to the headquarters any time they encounter issues. Instead, the bank provides branches (edge servers) in different locations to cater to the needs of their customers. Customers can easily walk into any branch nearest to them and get their issues or transactions sorted.</p>
<p>The branches have every customer's account information and transaction logs (cached data). Every branch of that bank delivers the same services and can satisfy their customers regardless of their distance from the headquarters.</p>
<p>The distribution of branches in different locations helps reduce the traffic that would have caused delays if the bank had just the headquarters as the only option. On contacting the bank's customer service on an issue, you would most likely be redirected to the nearest bank branch to you (DNS Routing)!</p>
<h2 id="heading-why-are-cdns-important"><strong>Why are CDNs Important?</strong></h2>
<p>There are many reasons why CDNs many websites use CDNs these days. Some of the key benefits are:</p>
<ol>
<li><p><strong>Improved Website Performance:</strong> CDNs can compress files and optimize images automatically, which helps speed up load time.</p>
</li>
<li><p><strong>Efficient Resource Storage:</strong> With CDNs, styling resources are stored and managed properly. Resources are also stored in files matching their content types.</p>
</li>
<li><p><strong>Better Search Engine Optimization (SEO):</strong> Using CDNs directly speeds up load time which in turn impacts search engine rankings. Google considers site speed a key metric that allows web pages to show up higher in search engines.</p>
</li>
<li><p><strong>Better User Experience:</strong> Users prefer faster and more responsive websites to slow and unresponsive ones. With a better user experience, a website is sure to receive more engagement and lower bounce rates.</p>
</li>
</ol>
<h2 id="heading-different-ways-to-use-a-cdn"><strong>Different Ways to Use a CDN</strong></h2>
<p>There are three ways you can access CDN resources in your project:</p>
<ul>
<li><p>Remote Hosting</p>
</li>
<li><p>Local Hosting</p>
</li>
<li><p>Hybrid Hosting</p>
</li>
</ul>
<h3 id="heading-remote-hosted-cdn"><strong>Remote Hosted CDN</strong></h3>
<p>Remote CDN links allow developers to access styling resources from a third-party server by simply linking to the CDN in their HTML files via the <code>link</code> or <code>script</code> tag.</p>
<p>Bootstrap, for example, has two primary CDN links – one for CSS stylesheet and another for JavaScript (handles dynamic interaction like dropdowns, pop-overs, and so on).</p>
<p>To use a Bootstrap stylesheet in your project, you need to add this single line - <code>https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css</code></p>
<p>And for the JavaScript: <code>https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js</code></p>
<h4 id="heading-how-to-find-remote-cdn-links"><strong>How to find remote CDN links</strong></h4>
<p>The best way to identify thte remote CDN links of your desired styling tool is to visit their official documentation site and look for the direct links there.</p>
<h4 id="heading-advantages-of-a-remote-cdn"><strong>Advantages of a remote CDN:</strong></h4>
<ol>
<li><p><strong>Easy to Use:</strong> You don’t need to download, manage, or upload files with CDN links. All you need to do is insert a single line of code in your HTML file and you are good to go.</p>
</li>
<li><p><strong>Global Caching:</strong> whenever you visit a website that uses CDN links, it downloads the resources on loading the page and then saves it in your browser cache. On subsequent visits to the same website or other sites that use the same CDN, it fetches from the cache and displays these resources more quickly. This is one of the biggest advantages of using CDN links, as it improves website load time.</p>
</li>
<li><p><strong>Optimized Global Delivery:</strong> CDNs are built to deliver content to users around the world by serving files from edge servers closest to users. This helps reduce the time it takes data to transfer across a network, also known as latency, and boosts performance for international users.</p>
</li>
<li><p><strong>Reduced Server Load:</strong> Due to the CDN fetching data from an external source, the load on your server is reduced, which is helpful for high-traffic websites.</p>
</li>
<li><p><strong>Real-Time Updates:</strong> Companies that own CDN links carry out periodic bug fixing, security patching, and feature updates, which can be beneficial for your project. These updates are reflected as soon as they are released.</p>
</li>
</ol>
<h4 id="heading-disadvantages-of-a-remote-cdn"><strong>Disadvantages of a remote CDN:</strong></h4>
<ol>
<li><p><strong>Customization Limitations:</strong> Styling components in remote CDNs are standard and unmodified. To modify them, you would have to override the specific styles in your local file which can introduce complexities.</p>
</li>
<li><p><strong>No Control over Updates:</strong> When automatic updates are made, they can cause problems in your web applications. If the changes being introduced include drastic changes, it can affect your website’s layout or behavior in a big way.</p>
</li>
<li><p><strong>Dependency on Third-Party Availability:</strong> If the CDN service experiences hitches like downtime or slowness, it can lead to broken styles thus, affecting your site’s performance negatively.</p>
</li>
<li><p><strong>Privacy and Security Concerns:</strong> Links referencing an external source can pose serious security concerns, as they can be used to track users and get vital information. It is important to include only trusted CDN link sources in your web project to avoid breaches.</p>
</li>
</ol>
<h3 id="heading-locally-hosted-cdn"><strong>Locally Hosted CDN</strong></h3>
<p>These are CDN resources downloaded from a remote CDN and saved within your project folder or hosted on a local server. This approach allows you to have full control over the resources.</p>
<h4 id="heading-how-to-host-cdn-resources-locally"><strong>How to host CDN resources locally:</strong></h4>
<p>Hosting locally is straightforward and easy. All you have to do is:</p>
<ul>
<li><p>Access the resource by navigating to the CDN link URL (for example, <a target="_blank" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"><code>https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css</code></a>).</p>
</li>
<li><p>Copy the code found in the URL.</p>
</li>
<li><p>Create a file with the appropriate file extension (.css, .js) within your project folder.</p>
</li>
<li><p>Paste and save.</p>
</li>
<li><p>Reference the file in your HTML document.</p>
</li>
</ul>
<p>If you follow these steps, you should be able to localize the CDN resource and access its styling locally.</p>
<h4 id="heading-advantages-of-a-locally-hosted-cdn"><strong>Advantages of a locally hosted CDN:</strong></h4>
<ol>
<li><p><strong>Full Control over Files:</strong> With resources resident within your project folder/server, you’re in full control of your files as there will be no unexpected outages, changes, or updates that might break your site.</p>
</li>
<li><p><strong>Offline Availability:</strong> Local hosting ensures that your styling resources are always available, especially for users with little or no network. This is perfect for building Progressive Web Applications (PWAs)<strong>.</strong></p>
</li>
<li><p><strong>Customization:</strong> There’s be no need for overrides, as your styling can be modified from within your project files.</p>
</li>
<li><p><strong>Security:</strong> By localizing CDN resources, you reduce the risk of potential third-party attacks on your project to the barest minimum.</p>
</li>
</ol>
<h4 id="heading-disadvantages-of-a-locally-hosted-cdn"><strong>Disadvantages of a locally hosted CDN:</strong></h4>
<ol>
<li><p><strong>No Global Caching:</strong> There is no benefit of global caching when resources are hosted locally. This will result in slower load time for first-time visitors.</p>
</li>
<li><p><strong>Increased Server Load:</strong> With files residing locally, the load on the server increases especially as traffic increases. This approach puts a burden on the server and its capacity has to be considered.</p>
</li>
<li><p><strong>Manual Updates:</strong> While hosting locally gives you control over updates, you’ll need to manually track and apply updates to your stylesheets when necessary. Also, missing security updates could make your site vulnerable.</p>
</li>
<li><p><strong>Regional Performance Impact:</strong> If your server is located in a specific region, users from faraway places may encounter slower load times because the content has to travel greater distances.</p>
</li>
</ol>
<h3 id="heading-hybrid-hosted-cdn"><strong>Hybrid Hosted CDN</strong></h3>
<p>This approach involves the combination of using both the remote link and local hosting of CDN resources. A hybrid approach – which involves using remote CDNs for core libraries and local hosting for custom stylesheets – may strike the perfect balance between performance and control.</p>
<h3 id="heading-best-approach-to-use"><strong>Best Approach to Use</strong></h3>
<p>The decision between remote and local hosting of of your CDN styling resources depends on factors such as project performance needs, user base, and security. Your choice should depend on the suitability of the approach to your project and should elevate the performance levels.</p>
<h4 id="heading-best-use-cases-for-a-remote-cdn"><strong>Best use-cases for a remote CDN:</strong></h4>
<ol>
<li><p><strong>Global User Base:</strong> If your website is to be accessed by a large, globally distributed audience, using the remote option would work best due to its performance and caching advantage.</p>
</li>
<li><p><strong>Fast Integration:</strong> In a situation where you want to develop and deploy a project in the shortest period of time, using the remote CDN link is quick and easy.</p>
</li>
<li><p><strong>Low-Traffic Website:</strong> Small projects such as portfolio sites and blogs are better served using a remote CDN link so as not to put a strain on the server. It also leads to easier implementation.</p>
</li>
</ol>
<h4 id="heading-best-use-cases-for-a-locally-hosted-cdn"><strong>Best use-cases for a locally hosted CDN:</strong></h4>
<ol>
<li><p><strong>High Security Needs:</strong> For applications that require tight security due to the sensitivity of their operations, hosting the CDN resources locally will reduce third-party risks and vulnerabilities.</p>
</li>
<li><p><strong>Offline Applications:</strong> For web applications that work offline, localizing styling resources would be the best option.</p>
</li>
<li><p><strong>Customization Requirements:</strong> If you need to create your tailored styling versions, hosting them locally is the best option.</p>
</li>
</ol>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>In this guide, you’ve learned what a CDN is, how you can host your CDN, and some of the benefits, drawbacks, and best use-cases for each approach.</p>
<p>Remote CDNs provide speed, convenience and reduced server load, while local hosting offers greater control, security, and customization options.</p>
<p>Ultimately, the best approach depends on your specific use case, audience, and priorities.</p>
<p>You can connect with me on <a target="_blank" href="https://www.linkedin.com/in/timothy-olanrewaju750/">LinkedIn</a> or <a target="_blank" href="https://x.com/SmoothTee_DC">X</a> for more frontend-related posts and articles.</p>
<p>See you on the next one!</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
