{"id":24456,"date":"2019-04-18T12:15:05","date_gmt":"2019-04-18T09:15:05","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=24456"},"modified":"2019-04-16T11:26:51","modified_gmt":"2019-04-16T08:26:51","slug":"caching-modules-nodejs","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/","title":{"rendered":"Caching of Modules in NodeJS"},"content":{"rendered":"\n<p>In this post, I am talking about caching of Modules in NodeJS.<\/p>\n\n\n\n<p>We have the following files<\/p>\n\n\n\n<div>\n<div id=\"highlighter_300995\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<div class=\"line number6 index5 alt1\">6<\/div>\n<div class=\"line number7 index6 alt2\">7<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php comments\">\/\/greet.js<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"php plain\">module.exports = {<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"php spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"php plain\">greeting: <\/code><code class=\"php string\">\"Hello!\"<\/code><code class=\"php plain\">,<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"php spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"php plain\">greet: <\/code><code class=\"php keyword\">function<\/code><code class=\"php plain\">(){<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"php spaces\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"php plain\">console.log(this.greeting);<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"php spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"php plain\">}<\/code><\/div>\n<div class=\"line number7 index6 alt2\"><code class=\"php plain\">}<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<div>\n<div id=\"highlighter_377224\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">01<\/div>\n<div class=\"line number2 index1 alt1\">02<\/div>\n<div class=\"line number3 index2 alt2\">03<\/div>\n<div class=\"line number4 index3 alt1\">04<\/div>\n<div class=\"line number5 index4 alt2\">05<\/div>\n<div class=\"line number6 index5 alt1\">06<\/div>\n<div class=\"line number7 index6 alt2\">07<\/div>\n<div class=\"line number8 index7 alt1\">08<\/div>\n<div class=\"line number9 index8 alt2\">09<\/div>\n<div class=\"line number10 index9 alt1\">10<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php comments\">\/\/app.js<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"php keyword\">var<\/code> <code class=\"php plain\">greet1 = <\/code><code class=\"php keyword\">require<\/code><code class=\"php plain\">(<\/code><code class=\"php string\">\".\/module\/greet\"<\/code><code class=\"php plain\">);<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"php plain\">greet1.greet();<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"php plain\">greet1.greeting = <\/code><code class=\"php string\">\"Yooo!\"<\/code><code class=\"php plain\">;<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"php plain\">greet1.greet();<\/code><\/div>\n<div class=\"line number6 index5 alt1\">&nbsp;<\/div>\n<div class=\"line number7 index6 alt2\">&nbsp;<\/div>\n<div class=\"line number8 index7 alt1\">&nbsp;<\/div>\n<div class=\"line number9 index8 alt2\"><code class=\"php keyword\">var<\/code> <code class=\"php plain\">greet2 =&nbsp; <\/code><code class=\"php keyword\">require<\/code><code class=\"php plain\">(<\/code><code class=\"php string\">\".\/module\/greet\"<\/code><code class=\"php plain\">);<\/code><\/div>\n<div class=\"line number10 index9 alt1\"><code class=\"php plain\">greet2.greet();<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>On executing <code>node app.js<\/code>, on first glance, we\u2019d expect the output to be:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_670843\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php plain\">Heyyyyyy?<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"php plain\">Yooo!<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"php plain\">Heyyyyyy?<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>Our logic is that <code>greet2.greet() <\/code>would print \u201cHeyyyyyy?\u201d because it\u2019ll get a fresh copy of module.export from greet.js file.<\/p>\n\n\n\n<p>But on the contrary, the output of the above program is:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_535917\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php plain\">Heyyyyyy? <\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"php plain\">Yooo! <\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"php plain\">Yooo!<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>So what actually happens is that \u2013 when <code>greet1 <\/code>function calls&nbsp;<code>require(\".\/module\/greet\")<\/code>function, a new module for&nbsp;<code>greet.js<\/code>is created and compiled. After compilation and before returning node stores the cached copy of <code>module.exports <\/code>in the variable <code>cachedModule.exports<\/code>, and then returns <code>module.exports<\/code><\/p>\n\n\n\n<p>Since objects in Javascript are passed by reference,&nbsp;<code>cachedModule.exports<\/code>points towards the same location in memory where <code>greet1 <\/code>points at. Now when we made a change to <code>greet1 <\/code>by mutating the <code>greeting <\/code>property, <code>cachedModule.exports <\/code>too changes because ultimately both&nbsp;<code>cachedModule.exports<\/code>and <code>greet1 <\/code>are the same. They point to the same object.<\/p>\n\n\n\n<p>So now when <code>greet2 <\/code>calls the&nbsp;<code>require(\".\/module\/greet\")<\/code>function, instead of recompiling <code>greet.js<\/code>, node <a href=\"https:\/\/github.com\/nodejs\/node\/blob\/ed2c6965d2f901f3c786f9d24bcd57b2cd523611\/lib\/internal\/modules\/cjs\/loader.js#L584\">checks<\/a> if there\u2019s a cached copy of <code>module.exports.<\/code>If found, it <a href=\"https:\/\/github.com\/nodejs\/node\/blob\/ed2c6965d2f901f3c786f9d24bcd57b2cd523611\/lib\/internal\/modules\/cjs\/loader.js#L586\">returns<\/a> it and hence saves time which would\u2019ve got lost in recompiling <code>greet.js<\/code>.<\/p>\n\n\n\n<p>So <code>greet2 <\/code>essentially gets the same object which is pointed towards by <code>greet1<\/code>. This is the reason&nbsp;<code>greet2.greeting()<\/code>prints \u201cYooo!\u201d.<\/p>\n\n\n\n<p>Node also provides a feature to delete the stored cache. It\u2019s done by executing the following statement:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_766376\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php functions\">delete<\/code> <code class=\"php keyword\">require<\/code><code class=\"php plain\">.cache[<\/code><code class=\"php keyword\">require<\/code><code class=\"php plain\">.resolve(module)]<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>So if one wants to always reload the module, he can add this function:<\/p>\n\n\n\n<div>\n<div id=\"highlighter_471938\" class=\"syntaxhighlighter  php\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"php keyword\">function<\/code> <code class=\"php plain\">requireUncached(module){<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"php spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"php functions\">delete<\/code> <code class=\"php keyword\">require<\/code><code class=\"php plain\">.cache[<\/code><code class=\"php keyword\">require<\/code><code class=\"php plain\">.resolve(module)]<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"php spaces\">&nbsp;&nbsp;&nbsp;&nbsp;<\/code><code class=\"php keyword\">return<\/code> <code class=\"php keyword\">require<\/code><code class=\"php plain\">(module)<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"php plain\">}<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p><strong>Takeaways from this lesson:<\/strong><\/p>\n\n\n\n<p>Whenever a module is required, node checks if there exists cached copy of its module.exports. If exists it returns the cached copy, otherwise it compiles that module and makes cached copy of its module.exports and then returns module.exports.<\/p>\n\n\n\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Web Code Geeks with permission by Himnash Jain, partner at our <a href=\"\/\/www.webcodegeeks.com\/join-us\/wcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">WCG program<\/a>. See the original article here: <a href=\"http:\/\/www.awasthiashish.com\/2019\/03\/caching-of-modules-in-nodejs.html\" target=\"_blank\" rel=\"noopener noreferrer\">Caching of Modules in NodeJS<\/a><\/p>\n<p>Opinions expressed by Web Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this post, I am talking about caching of Modules in NodeJS. We have the following files 1 2 3 4 5 6 7 \/\/greet.js module.exports = { &nbsp;&nbsp;&nbsp;&nbsp;greeting: &#8220;Hello!&#8221;, &nbsp;&nbsp;&nbsp;&nbsp;greet: function(){ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;console.log(this.greeting); &nbsp;&nbsp;&nbsp;&nbsp;} } 01 02 03 04 05 06 07 08 09 10 \/\/app.js var greet1 = require(&#8220;.\/module\/greet&#8221;); greet1.greet(); greet1.greeting = &#8220;Yooo!&#8221;; greet1.greet(); &hellip;<\/p>\n","protected":false},"author":12696,"featured_media":924,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-24456","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-node-js"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Caching of Modules in NodeJS - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn about Caching of Modules? Check our article explaining how you can achieve caching of Modules in NodeJS.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Caching of Modules in NodeJS - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Caching of Modules? Check our article explaining how you can achieve caching of Modules in NodeJS.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-04-18T09:15:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Himansh Jain\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Himansh Jain\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/\"},\"author\":{\"name\":\"Himansh Jain\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/4edd2a3a95a21e33a556b9f67be42685\"},\"headline\":\"Caching of Modules in NodeJS\",\"datePublished\":\"2019-04-18T09:15:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/\"},\"wordCount\":317,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg\",\"articleSection\":[\"Node.js\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/\",\"name\":\"Caching of Modules in NodeJS - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg\",\"datePublished\":\"2019-04-18T09:15:05+00:00\",\"description\":\"Interested to learn about Caching of Modules? Check our article explaining how you can achieve caching of Modules in NodeJS.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Node.js\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/node-js\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Caching of Modules in NodeJS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/4edd2a3a95a21e33a556b9f67be42685\",\"name\":\"Himansh Jain\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/817eafb54ed3311f0bbdea278a6acd240ceab2390ae7e6884338003811dbc831?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/817eafb54ed3311f0bbdea278a6acd240ceab2390ae7e6884338003811dbc831?s=96&d=mm&r=g\",\"caption\":\"Himansh Jain\"},\"description\":\"Works as the technical leader of an ADF Development team, An active member of OTN Jdev\/ADF Forum of Oracle Community. He has written more than 200 article about Oracle ADF and JDeveloper. Many of his articles got published in WebLogic community newsletter and Oracle ACE newsletter from time to time. Awarded with Oracle ACE title (\u2660\ufe0f) in the year 2015 for his contribution in Oracle Technology Network.\",\"sameAs\":[\"http:\/\/www.awasthiashish.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/himansh-jain\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Caching of Modules in NodeJS - Web Code Geeks - 2026","description":"Interested to learn about Caching of Modules? Check our article explaining how you can achieve caching of Modules in NodeJS.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/","og_locale":"en_US","og_type":"article","og_title":"Caching of Modules in NodeJS - Web Code Geeks - 2026","og_description":"Interested to learn about Caching of Modules? Check our article explaining how you can achieve caching of Modules in NodeJS.","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2019-04-18T09:15:05+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg","type":"image\/jpeg"}],"author":"Himansh Jain","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Himansh Jain","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/"},"author":{"name":"Himansh Jain","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/4edd2a3a95a21e33a556b9f67be42685"},"headline":"Caching of Modules in NodeJS","datePublished":"2019-04-18T09:15:05+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/"},"wordCount":317,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg","articleSection":["Node.js"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/","name":"Caching of Modules in NodeJS - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg","datePublished":"2019-04-18T09:15:05+00:00","description":"Interested to learn about Caching of Modules? Check our article explaining how you can achieve caching of Modules in NodeJS.","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/nodejs-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/node-js\/caching-modules-nodejs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Node.js","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/node-js\/"},{"@type":"ListItem","position":4,"name":"Caching of Modules in NodeJS"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/4edd2a3a95a21e33a556b9f67be42685","name":"Himansh Jain","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/817eafb54ed3311f0bbdea278a6acd240ceab2390ae7e6884338003811dbc831?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/817eafb54ed3311f0bbdea278a6acd240ceab2390ae7e6884338003811dbc831?s=96&d=mm&r=g","caption":"Himansh Jain"},"description":"Works as the technical leader of an ADF Development team, An active member of OTN Jdev\/ADF Forum of Oracle Community. He has written more than 200 article about Oracle ADF and JDeveloper. Many of his articles got published in WebLogic community newsletter and Oracle ACE newsletter from time to time. Awarded with Oracle ACE title (\u2660\ufe0f) in the year 2015 for his contribution in Oracle Technology Network.","sameAs":["http:\/\/www.awasthiashish.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/himansh-jain\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/24456","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/12696"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=24456"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/24456\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/924"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=24456"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=24456"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=24456"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}