<?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 Toshal T on Medium]]></title>
        <description><![CDATA[Stories by Toshal T on Medium]]></description>
        <link>https://medium.com/@toshal.t1?source=rss-db45a2c12839------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3EiMmAMIvK-MTEW2</url>
            <title>Stories by Toshal T on Medium</title>
            <link>https://medium.com/@toshal.t1?source=rss-db45a2c12839------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 17:03:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@toshal.t1/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[Caching]]></title>
            <link>https://medium.com/@toshal.t1/caching-af4c5af65a4f?source=rss-db45a2c12839------2</link>
            <guid isPermaLink="false">https://medium.com/p/af4c5af65a4f</guid>
            <category><![CDATA[caching]]></category>
            <dc:creator><![CDATA[Toshal T]]></dc:creator>
            <pubDate>Thu, 04 May 2023 20:41:51 GMT</pubDate>
            <atom:updated>2023-05-04T20:41:51.115Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>Caching is a mechanism that allows you to store frequently accessed data in a memory for quick access. It’s a critical part of any application or system that needs to handle large volumes of data and respond to requests quickly. In this article, we’ll explore caching, its benefits, and some of the popular caching techniques.</p><p><strong>What is Caching?</strong></p><p>Caching is the process of storing frequently accessed data in a memory to reduce the response time of a system. It’s similar to how you cache web pages on your browser to avoid having to fetch them every time you visit the same page. When you request the same page again, your browser loads it from the cache instead of fetching it from the server.</p><p>The same concept applies to computer systems. Instead of fetching data from a database or disk every time a request is made, you can store the data in memory and fetch it from there. This saves a significant amount of time and resources, especially when dealing with large datasets.</p><p><strong>Benefits of Caching</strong></p><p>Caching provides several benefits, including:</p><ol><li>Faster response times: Caching reduces the time required to fetch data, resulting in faster response times.</li><li>Reduced server load: By caching data, the server load is reduced since the data is fetched from the cache instead of being fetched from the server.</li><li>Improved scalability: Caching improves the scalability of a system since it can handle more requests per second.</li></ol><p><strong>Popular Caching Techniques</strong></p><ol><li><strong>Browser caching:</strong> This type of caching is performed by the browser itself and involves storing resources like images, stylesheets, and scripts in the cache. When a user visits a website, the browser checks if it already has the requested resources in the cache, and if it does, it retrieves them from the cache instead of downloading them again from the server. This type of caching is useful for improving website performance and reducing network traffic.</li><li><strong>Server-side caching:</strong> This type of caching is performed on the server-side and involves storing frequently accessed data in a cache. This can include database queries, API responses, and other server-side computations. By storing the results in a cache, the server can respond to subsequent requests faster and reduce the load on the server.</li><li><strong>Client-side caching:</strong> This type of caching is performed on the client-side and involves storing data in the client’s local storage or session storage. This is useful for storing user-specific data like preferences or shopping cart items. By storing the data in the client’s browser, the website can retrieve the data quickly and avoid having to fetch it from the server every time.</li><li><strong>Memoization:</strong> Memoization is a technique that involves caching the results of function calls based on their arguments. This can be useful for expensive computations or functions that are called frequently with the same arguments. By caching the results, the function can return the cached value instead of recalculating it every time it’s called with the same arguments.</li><li><strong>CDN caching</strong>: Content Delivery Networks (CDNs) are used to distribute content like images, videos, and other assets across a network of servers around the world. When a user requests content from a CDN, the server closest to the user responds with the content. CDNs also cache content, so subsequent requests for the same content can be served faster.</li></ol><p><strong>Example:-</strong></p><p>This is simple example, to illustrates how caching works!…</p><pre>function caching(fn, context) {<br>  let result = {};<br>  return function (...args) {<br>    var agrsCache = JSON.stringify(args);<br>    if (!result[agrsCache]) {<br>      result[agrsCache] = fn.call(context || this, ...args);<br>    }<br>    console.log(result)<br>    return result[agrsCache];<br>  };<br>}<br><br>const abc = (num1, num2) =&gt; {<br>  for (let i = 0; i &lt;= 100000000; i++) {}<br>  return num1 * num2;<br>};<br><br>const myFunc = caching(abc);<br>console.log(myFunc());<br><br>// console.time(&quot;first call&quot;);<br>console.log(abc(123, 123));<br>// console.lastTime(&quot;lastTime&quot;);</pre><p><strong>Conclusion</strong></p><p>Caching is a powerful technique for improving performance and reducing network traffic in JavaScript applications. Browser caching, server-side caching, client-side caching, memoization, and CDN caching are some of the common types of caching in JavaScript. By understanding the different types of caching, developers can choose the most appropriate caching strategy for their application and improve its performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af4c5af65a4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>