[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"verticals":3,"search-suggestions":44,"article-nextjs-weekly-use-cache-remote-vs-private":93,"path-membership-nextjs-weekly-use-cache-remote-vs-private":513,"related-nextjs-weekly-use-cache-remote-vs-private":514,"code:ts:true:1iv2hma":624,"code:tsx:true:1ywdwiy":625,"code:tsx:true:1bkbffk":626,"code:tsx:true:1f2u7l3":627,"code:text:true:1ve6phm":628,"comments-01a1fce0-ce76-7424-b4da-6db21c69992c":629},[4,20,32],{"id":5,"slug":6,"name":7,"tagline":8,"description":9,"accentFrom":10,"accentTo":11,"icon":12,"defaultLocale":13,"locales":14,"features":16,"position":19},"019fe637-3d33-714b-b57f-23e163ffca0c","dev","Web Development","Read it. Run it. Prove it.","A post a day on modern web development — most with an editable playground and a quiz that explains every answer. Free, no account needed.","violet-500","cyan-400","◇","en",[13,15],"fa",{"courses":17,"paths":17,"articles":17,"exams":18,"flashcards":18,"packages":17,"community":17,"certificates":17,"teams":17,"commerce":17},true,false,0,{"id":21,"slug":22,"name":23,"tagline":24,"description":25,"accentFrom":26,"accentTo":10,"icon":27,"defaultLocale":13,"locales":28,"features":30,"position":31},"019fe637-3dc2-754c-8657-0f175bfee7c6","lang","Languages","Learn a language the way you learn a codebase.","Grammar explained the way good documentation explains an API — one idea at a time, each with a quiz.","amber-400","⌘",[13,15,29],"es",{"courses":18,"paths":18,"articles":17,"exams":18,"flashcards":17,"packages":18,"community":17,"certificates":17,"teams":18,"commerce":18},2,{"id":33,"slug":34,"name":35,"tagline":36,"description":37,"accentFrom":38,"accentTo":39,"icon":40,"defaultLocale":13,"locales":41,"features":42,"position":43},"7b3c16f2-931d-410e-802e-e1fa4edab7de","soft","Soft Skills","The half of the job nobody wrote documentation for.","Weekly, on the parts of working life that decide more than your code does — first weeks, meetings, interviews, promotions, and the people around you. Written from what actually happens, and recorded as a podcast you can listen to on the walk.","emerald-400","teal-300","◉",[13],{"courses":18,"paths":18,"articles":17,"exams":18,"flashcards":18,"packages":18,"community":17,"certificates":18,"teams":18,"commerce":18},3,[45,49,53,57,61,65,69,73,77,81,85,89],{"slug":46,"name":47,"articles":48},"webdev","Webdev",195,{"slug":50,"name":51,"articles":52},"javascript","Javascript",156,{"slug":54,"name":55,"articles":56},"frontend","Frontend",103,{"slug":58,"name":59,"articles":60},"tutorial","Tutorial",85,{"slug":62,"name":63,"articles":64},"css","Css",56,{"slug":66,"name":67,"articles":68},"typescript","Typescript",36,{"slug":70,"name":71,"articles":72},"performance","Performance",33,{"slug":74,"name":75,"articles":76},"programming","Programming",26,{"slug":78,"name":79,"articles":80},"react","React",23,{"slug":82,"name":83,"articles":84},"node","Node",19,{"slug":86,"name":87,"articles":88},"browser","Browser",18,{"slug":90,"name":91,"articles":92},"nextjs","Nextjs",13,{"id":94,"slug":95,"title":96,"subtitle":97,"excerpt":98,"coverUrl":99,"locale":13,"readingMinutes":100,"publishedAt":101,"viewCount":102,"likeCount":19,"commentCount":19,"author":103,"vertical":108,"topic":109,"tags":110,"_count":115,"playground":117,"body":119,"bodyMd":442,"seo":443,"translationGroupId":445,"series":446,"podcastUrl":97,"verticalId":5,"thread":501,"assessments":503,"translations":509,"quiz":511},"01a1fce0-ce76-7424-b4da-6db21c69992c","nextjs-weekly-use-cache-remote-vs-private","Next.js 16 use cache: remote vs use cache: private",null,"Next.js 16's use cache: remote shares a cache across instances; use cache: private never leaves one request. Which to pick, plus a copy-paste cheat sheet.","\u002Fmedia\u002Fcovers\u002Fnextjs-weekly-use-cache-remote-vs-private.png",16,"2026-11-27T11:47:29.944Z",28,{"id":104,"name":105,"username":106,"avatarUrl":97,"headline":107},"019fe637-3c25-7088-9034-39c9f15dc3c8","Parsa Jiravand","parsa","Frontend engineer · building bestpractic",{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":90,"name":91},[111,112,113,114],{"slug":90,"name":91,"color":97},{"slug":46,"name":47,"color":97},{"slug":58,"name":59,"color":97},{"slug":50,"name":51,"color":97},{"assessments":116},1,{"slug":95,"title":118},"Next.js use cache: remote vs use cache: private — interactive model",{"blocks":120,"version":116},[121,125,128,131,136,139,147,150,153,156,169,173,176,179,184,187,190,193,215,218,222,225,231,234,237,241,244,249,252,255,259,262,266,269,272,275,278,281,286,290,293,296,304,307,315,318,321,324,327,330,333,341,344,347,350,353,356,359,362,366,369,373,376,380,383,387,390,394,397,401,404,407,412,415,418,424,427,430,433,436],{"id":122,"html":123,"type":124},"b1","\u003Cp>A team ships personalized product recommendations on a product page. The data depends on the visitor&#39;s session cookie, so a teammate wraps the fetch in a plain \u003Ccode>&#39;use cache&#39;\u003C\u002Fcode> function and reads \u003Ccode>cookies()\u003C\u002Fcode> inside it. \u003Ccode>next build\u003C\u002Fcode> passes. \u003Ccode>next start\u003C\u002Fcode> doesn&#39;t: every request to that route throws \u003Ccode>next-request-in-use-cache\u003C\u002Fcode>, because \u003Ccode>use cache\u003C\u002Fcode> cannot see request-time APIs at all, by design.\u003C\u002Fp>","paragraph",{"id":126,"html":127,"type":124},"b2","\u003Cp>The fix looks obvious: switch to \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode>, since the docs say it&#39;s the directive that can read cookies. It compiles, it renders, the recommendations are personalized again — and the team, having just learned there&#39;s a &quot;private&quot; cache, applies it everywhere else that used to be a plain \u003Ccode>fetch\u003C\u002Fcode>, including the currency-converted price that&#39;s genuinely the same for every visitor paying in USD. Three weeks later, the pricing API is getting hammered on every cold start in production, because \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode> was never meant to deduplicate shared data across users — it isn&#39;t that kind of cache at all.\u003C\u002Fp>",{"id":129,"html":130,"type":124},"b3","\u003Cp>This is the mix-up this article exists to prevent. Next.js 16 ships \u003Cstrong>three\u003C\u002Fstrong> caching directives under Cache Components — \u003Ccode>use cache\u003C\u002Fcode>, \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode>, and \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> — and they answer three different questions, not one question three ways. This article is written against \u003Cstrong>Next.js 16.4.6\u003C\u002Fstrong> (verified against the framework&#39;s own bundled documentation and npm&#39;s \u003Ccode>latest\u003C\u002Fcode> dist-tag in November 2026); both private and remote caches were introduced and stabilized together with Cache Components in Next.js 16.0.0.\u003C\u002Fp>",{"id":132,"html":133,"text":134,"type":135,"level":31},"b4","What you&#39;ll learn","What you'll learn","heading",{"id":137,"html":138,"type":124},"b5","\u003Cp>By the end of this article you&#39;ll be able to:\u003C\u002Fp>",{"id":140,"type":141,"items":142,"ordered":18},"b6","list",[143,144,145,146],"Explain what each of the three \u003Ccode>use cache\u003C\u002Fcode> directives actually stores, and where","Pick the right one for personalized data, for shared-but-expensive data, and for everything else","Read the nesting rules that decide which directives can wrap which","Avoid the two opposite mistakes: caching personal data where it could leak, and caching shared data where it never gets reused",{"id":148,"html":149,"text":149,"type":135,"level":31},"b7","Who this is for",{"id":151,"html":152,"type":124},"b8","\u003Cp>You&#39;re already caching something with plain \u003Ccode>&#39;use cache&#39;\u003C\u002Fcode> — or you&#39;ve read \u003Ca href=\"https:\u002F\u002Fdev.to\u002Fparsajiravand\u002Fnextjs-cache-components-explained-with-cheat-sheet-55ob\">Next.js Cache Components Explained\u003C\u002Fa>, which builds that foundation from nothing. This article assumes that part and goes one level deeper, into the two directives that exist specifically for data \u003Ccode>use cache\u003C\u002Fcode> can&#39;t handle. You don&#39;t need to have read it first; the rules below stand on their own.\u003C\u002Fp>",{"id":154,"html":155,"text":155,"type":135,"level":31},"b9","Table of contents",{"id":157,"type":141,"items":158,"ordered":18},"b10",[159,160,161,162,163,164,165,166,167,168],"\u003Ca href=\"#the-problem-one-cache-three-jobs-it-cant-all-do\">The problem: one cache, three jobs it can&#39;t all do\u003C\u002Fa>","\u003Ca href=\"#the-mental-model-scope-and-storage-are-two-different-dials\">The mental model: scope and storage are two different dials\u003C\u002Fa>","\u003Ca href=\"#stage-1-the-baseline-what-plain-use-cache-wont-do\">Stage 1: the baseline — what plain \u003Ccode>use cache\u003C\u002Fcode> won&#39;t do\u003C\u002Fa>","\u003Ca href=\"#stage-2-use-cache-private-per-request-never-shared\">Stage 2: \u003Ccode>use cache: private\u003C\u002Fcode> — per-request, never shared\u003C\u002Fa>","\u003Ca href=\"#stage-3-use-cache-remote-shared-across-every-instance\">Stage 3: \u003Ccode>use cache: remote\u003C\u002Fcode> — shared across every instance\u003C\u002Fa>","\u003Ca href=\"#stage-4-the-nesting-rules\">Stage 4: the nesting rules\u003C\u002Fa>","\u003Ca href=\"#edge-cases-and-gotchas\">Edge cases and gotchas\u003C\u002Fa>","\u003Ca href=\"#best-practices\">Best practices\u003C\u002Fa>","\u003Ca href=\"#faq\">FAQ\u003C\u002Fa>","\u003Ca href=\"#cheat-sheet\">Cheat sheet\u003C\u002Fa>",{"id":170,"html":171,"text":172,"type":135,"level":31},"b11","The problem: one cache, three jobs it can&#39;t all do","The problem: one cache, three jobs it can't all do",{"id":174,"html":175,"type":124},"b12","\u003Cp>Plain \u003Ccode>use cache\u003C\u002Fcode> does two jobs at once: it tells Next.js what&#39;s safe to put in a route&#39;s prerendered \u003Cstrong>static shell\u003C\u002Fstrong>, and it caches a function&#39;s result so repeat calls with the same inputs skip the work. Both jobs assume the same thing — that the cached value is identical for every visitor who triggers the same inputs. That assumption breaks the moment a value depends on \u003Cem>who&#39;s asking\u003C\u002Fem>, which is exactly why \u003Ccode>use cache\u003C\u002Fcode> refuses to let you read \u003Ccode>cookies()\u003C\u002Fcode>, \u003Ccode>headers()\u003C\u002Fcode>, or \u003Ccode>searchParams\u003C\u002Fcode> inside it: there&#39;d be no safe single value to put in a shell every visitor shares.\u003C\u002Fp>",{"id":177,"html":178,"type":124},"b13","\u003Cp>So the framework splits the &quot;who&#39;s asking&quot; problem into two separate directives, one for each half of it:\u003C\u002Fp>",{"id":180,"type":141,"items":181,"ordered":18},"b14",[182,183],"Sometimes the answer genuinely differs \u003Cstrong>per visitor\u003C\u002Fstrong> and must never be handed to anyone else — that&#39;s \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode>.","Sometimes the answer is the same for \u003Cstrong>many\u003C\u002Fstrong> visitors (same currency, same language, same product category) but you still need to defer reading it until request time, and the default in-memory cache isn&#39;t durable enough across your server instances — that&#39;s \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode>.",{"id":185,"html":186,"type":124},"b15","\u003Cp>Neither one is &quot;the private version&quot; or &quot;the bigger version&quot; of the other. They answer different questions, and reaching for the wrong one either leaks nothing useful (over-caching data that was never personal) or hammers your backend (under-caching data that should have been shared).\u003C\u002Fp>",{"id":188,"html":189,"text":189,"type":135,"level":31},"b16","The mental model: scope and storage are two different dials",{"id":191,"html":192,"type":124},"b17","\u003Cp>\u003Cstrong>The mental model:\u003C\u002Fstrong> every cache in Next.js is the product of two independent choices — who the cached value is allowed to be \u003Cem>shared with\u003C\u002Fem> (scope), and \u003Cem>where it physically lives\u003C\u002Fem> (storage). Conflating these two dials is the whole source of confusion here.\u003C\u002Fp>",{"id":194,"head":195,"rows":200,"type":214},"b18",[196,197,198,199],"","\u003Ccode>use cache\u003C\u002Fcode>","\u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode>","\u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode>",[201,205,210],[202,203,203,204],"\u003Cstrong>Scope\u003C\u002Fstrong> — who shares one entry","Everyone","Nobody but this one request",[206,207,208,209],"\u003Cstrong>Storage\u003C\u002Fstrong> — where it lives","In-memory (or a configured handler)","A remote cache handler (Redis, KV, …)","Nowhere persistent — not saved across requests in production",[211,212,212,213],"\u003Cstrong>Can read \u003Ccode>cookies()\u003C\u002Fcode> \u002F \u003Ccode>headers()\u003C\u002Fcode>\u003C\u002Fstrong>","No","Yes","table",{"id":216,"html":217,"type":124},"b19","\u003Cp>Read the table by column, not by row: \u003Ccode>use cache\u003C\u002Fcode> and \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> share the same scope (everyone) and differ only in storage durability. \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode> is the odd one out on scope — it exists purely to let request-specific code participate in caching at all, and the tradeoff for that access is that nothing it produces gets saved across requests.\u003C\u002Fp>",{"id":219,"html":220,"text":221,"type":135,"level":31},"b20","Stage 1: the baseline — what plain \u003Ccode>use cache\u003C\u002Fcode> won&#39;t do","Stage 1: the baseline — what plain use cache won't do",{"id":223,"html":224,"type":124},"b21","\u003Cp>A quick recap, since both of today&#39;s directives are defined by contrast to this one. A plain cached function looks like this:\u003C\u002Fp>",{"id":226,"code":227,"type":228,"language":229,"highlight":230},"b22","\u002F\u002F app\u002Flib\u002Fpricing.ts\nimport { cacheLife } from 'next\u002Fcache';\n\nexport async function getBasePrice(productId: string) {\n  'use cache';\n  cacheLife('hours');\n  return db.products.getPrice(productId);\n}","code","ts",[],{"id":232,"html":233,"type":124},"b23","\u003Cp>This is shared across every visitor who asks for the same \u003Ccode>productId\u003C\u002Fcode>, and it can contribute to the route&#39;s static shell. The constraint: this function, and anything it calls, cannot touch \u003Ccode>cookies()\u003C\u002Fcode>, \u003Ccode>headers()\u003C\u002Fcode>, or \u003Ccode>searchParams\u003C\u002Fcode> — doing so throws \u003Ccode>next-request-in-use-cache\u003C\u002Fcode> the moment the route actually runs, even though \u003Ccode>next build\u003C\u002Fcode> may not have caught it.\u003C\u002Fp>",{"id":235,"html":236,"type":124},"b24","\u003Cp>\u003Cstrong>Key concept:\u003C\u002Fstrong> \u003Ccode>use cache\u003C\u002Fcode> isn&#39;t refusing to be &quot;dynamic&quot; out of caution — it genuinely has nowhere safe to put a per-visitor answer. That gap is exactly what the next two directives exist to fill, each for a different reason.\u003C\u002Fp>",{"id":238,"html":239,"text":240,"type":135,"level":31},"b25","Stage 2: \u003Ccode>use cache: private\u003C\u002Fcode> — per-request, never shared","Stage 2: use cache: private — per-request, never shared",{"id":242,"html":243,"type":124},"b26","\u003Cp>\u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode> lifts the ban on request-time APIs, at the cost of never sharing the result:\u003C\u002Fp>",{"id":245,"code":246,"type":228,"language":247,"highlight":248},"b27","\u002F\u002F app\u002Fproduct\u002F[id]\u002Fpage.tsx\nimport { Suspense } from 'react';\nimport { cookies } from 'next\u002Fheaders';\nimport { cacheLife, cacheTag } from 'next\u002Fcache';\n\nexport default async function ProductPage({ params }: { params: Promise\u003C{ id: string }> }) {\n  const { id } = await params;\n  return (\n    \u003CSuspense fallback={\u003Cdiv>Loading recommendations...\u003C\u002Fdiv>}>\n      \u003CRecommendations productId={id} \u002F>\n    \u003C\u002FSuspense>\n  );\n}\n\nasync function Recommendations({ productId }: { productId: string }) {\n  const sessionId = (await cookies()).get('session-id')?.value ?? 'guest';\n  const recs = await getRecommendations(productId, sessionId);\n  return \u003CRecList items={recs} \u002F>;\n}\n\nasync function getRecommendations(productId: string, sessionId: string) {\n  'use cache: private';\n  cacheTag(`recommendations-${productId}`);\n  cacheLife({ stale: 60 });\n  return db.recommendations.personalize(productId, sessionId);\n}","tsx",[],{"id":250,"html":251,"type":124},"b28","\u003Cp>In production, calling this function twice \u003Cem>within the same request\u003C\u002Fem> can reuse the result — that&#39;s request-scoped deduplication, not a server cache. It is never written to a cache that a later request, from the same visitor or anyone else, can read. In development, Next.js does keep it in memory, keyed by that request&#39;s cookies and headers, so you can watch it serve a near-identical dev request from cache — which is useful for iterating locally, but isn&#39;t the production behavior.\u003C\u002Fp>",{"id":253,"html":254,"type":124},"b29","\u003Cp>\u003Cstrong>Key concept:\u003C\u002Fstrong> the \u003Ccode>stale\u003C\u002Fcode> time you set with \u003Ccode>cacheLife\u003C\u002Fcode> governs the \u003Cem>client-side\u003C\u002Fem> router cache, not a server store. Private cache functions are excluded from static-shell generation entirely, so this value only controls how long the browser can reuse what it already streamed down. The docs call out a specific threshold: \u003Ccode>stale\u003C\u002Fcode> must be at least 30 seconds for per-link prefetching to work, and at least 5 minutes for the content to be eligible for the route&#39;s App Shell. If a function only needs within-request dedup and shouldn&#39;t shorten the route&#39;s overall client stale time, set \u003Ccode>cacheLife({ stale: Infinity })\u003C\u002Fcode> — that opts it out of influencing the route&#39;s shortest stale time without claiming server persistence it was never going to get.\u003C\u002Fp>",{"id":256,"html":257,"text":258,"type":135,"level":31},"b30","Stage 3: \u003Ccode>use cache: remote\u003C\u002Fcode> — shared across every instance","Stage 3: use cache: remote — shared across every instance",{"id":260,"html":261,"type":124},"b31","\u003Cp>\u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> solves a completely different problem: \u003Ccode>use cache\u003C\u002Fcode>&#39;s default in-memory store is just that — in-memory, per instance. In a serverless deployment, each invocation can land on a different, short-lived instance, so the in-memory cache barely helps; every cold instance re-runs the work and re-hits your backend.\u003C\u002Fp>",{"id":263,"code":264,"type":228,"language":247,"highlight":265},"b32","\u002F\u002F app\u002Fproduct\u002F[id]\u002Fpage.tsx\nimport { Suspense } from 'react';\nimport { cookies } from 'next\u002Fheaders';\nimport { cacheTag, cacheLife } from 'next\u002Fcache';\n\nasync function ProductPrice({ productId }: { productId: string }) {\n  \u002F\u002F Reading cookies defers this component to request time\n  const currency = (await cookies()).get('currency')?.value ?? 'USD';\n  const price = await getProductPrice(productId, currency);\n  return \u003Cdiv>Price: {price} {currency}\u003C\u002Fdiv>;\n}\n\nasync function getProductPrice(productId: string, currency: string) {\n  'use cache: remote';\n  cacheTag(`product-price-${productId}`);\n  cacheLife({ expire: 3600 }); \u002F\u002F 1 hour\n\n  \u002F\u002F Cached per (productId, currency) — a handful of currencies, not one entry per visitor\n  return db.products.getPrice(productId, currency);\n}",[],{"id":267,"html":268,"type":124},"b33","\u003Cp>Notice what&#39;s \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode>, not \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode>, in this example: the price depends on \u003Ccode>currency\u003C\u002Fcode>, which is read from a cookie, but currency is shared across potentially thousands of visitors. Caching it as &quot;private&quot; would create one cache miss per visitor for data that&#39;s identical across a whole currency; caching it as &quot;remote&quot; creates one shared entry per currency and lets every server instance hit that same entry.\u003C\u002Fp>",{"id":270,"html":271,"type":124},"b34","\u003Cp>A remote cache needs a real handler — Redis, a KV store, anything configured through \u003Ca href=\"https:\u002F\u002Fnextjs.org\u002Fdocs\u002Fapp\u002Fapi-reference\u002Fconfig\u002Fnext-config-js\u002FcacheHandlers\">\u003Ccode>cacheHandlers\u003C\u002Fcode>\u003C\u002Fa> — which most hosting providers supply automatically, and which you configure yourself if you&#39;re self-hosting. That&#39;s the tradeoff \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> is explicit about: infrastructure cost and a network round trip on every lookup, in exchange for a cache that&#39;s actually shared once a request falls outside the static shell.\u003C\u002Fp>",{"id":273,"html":274,"type":124},"b35","\u003Cp>\u003Cstrong>Key concept:\u003C\u002Fstrong> reach for \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> only when the dimension you&#39;re caching on has \u003Cem>few\u003C\u002Fem> distinct values relative to your traffic (currencies, languages, categories — not user IDs or arbitrary search filters). The docs frame this as finding &quot;the dimension with fewer unique values&quot; and caching on that, then filtering the rest in memory. Cache on \u003Ccode>category\u003C\u002Fcode>, not on \u003Ccode>category + minPrice\u003C\u002Fcode>, and the hit rate difference is the entire point of paying for a remote handler at all.\u003C\u002Fp>",{"id":276,"html":277,"text":277,"type":135,"level":31},"b36","Stage 4: the nesting rules",{"id":279,"html":280,"type":124},"b37","\u003Cp>Because remote and private caches solve opposite problems, Next.js enforces where each can appear relative to the other:\u003C\u002Fp>",{"id":282,"type":141,"items":283,"ordered":18},"b38",[284,285],"A remote cache \u003Cstrong>can\u003C\u002Fstrong> nest inside another remote cache, or inside a plain \u003Ccode>use cache\u003C\u002Fcode>.","A remote cache \u003Cstrong>cannot\u003C\u002Fstrong> nest inside a private cache, in either direction.",{"id":287,"code":288,"type":228,"language":247,"highlight":289},"b39","\u002F\u002F VALID — remote inside a plain cache\nasync function outerCache() {\n  'use cache';\n  return innerRemote(); \u002F\u002F fine — resolved when deferred to request time\n}\n\n\u002F\u002F INVALID — remote inside private, or private inside remote, throws\nasync function outerPrivate() {\n  'use cache: private';\n  return innerRemote(); \u002F\u002F Error\n}",[],{"id":291,"html":292,"type":124},"b40","\u003Cp>The rule follows directly from the mental model: a private cache&#39;s entire contract is &quot;nothing here gets shared.&quot; Letting a shared remote cache live inside it (or vice versa) would mean one of the two guarantees has to break. Next.js enforces the rule at the boundary instead of leaving it to be discovered in production.\u003C\u002Fp>",{"id":294,"html":295,"text":295,"type":135,"level":31},"b41","Edge cases and gotchas",{"id":297,"type":141,"items":298,"ordered":18},"b42",[299,300,301,302,303],"\u003Cstrong>Remote caches don&#39;t survive a deploy.\u003C\u002Fstrong> The cache key for \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> includes your build ID (or \u003Ccode>deploymentId\u003C\u002Fcode>, if you&#39;ve configured one), so a new build produces entirely new keys. This is intentional — a refactored function or an upgraded dependency can quietly change what a cache entry means, and reusing an old entry under a new build risks serving data that doesn&#39;t match what the new code expects.","\u003Cstrong>Draft Mode bypasses \u003Ccode>use cache\u003C\u002Fcode>, no special case needed.\u003C\u002Fstrong> The docs are explicit about plain \u003Ccode>use cache\u003C\u002Fcode>: with Draft Mode enabled, cached functions and components re-execute on every request and their results aren&#39;t saved to the cache. \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode> already never persists across requests in production, so Draft Mode doesn&#39;t change anything there either way. The docs don&#39;t make the same statement by name for \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> — don&#39;t assume it behaves identically without checking your own cache handler.","\u003Cstrong>\u003Ccode>connection()\u003C\u002Fcode> is off-limits in both \u003Ccode>use cache\u003C\u002Fcode> and \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode>.\u003C\u002Fstrong> It&#39;s easy to assume &quot;private&quot; means &quot;anything request-related is now fair game,&quot; but \u003Ccode>connection()\u003C\u002Fcode> specifically carries connection-level information that isn&#39;t safe to cache even per-request, so it stays prohibited in both.","\u003Cstrong>You can&#39;t configure a custom handler for \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode>.\u003C\u002Fstrong> Unlike \u003Ccode>use cache\u003C\u002Fcode> and \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode>, there&#39;s no \u003Ccode>cacheHandlers\u003C\u002Fcode> hook for the private directive — by design, since it&#39;s defined by \u003Cem>not\u003C\u002Fem> persisting anywhere durable.","\u003Cstrong>&quot;Private&quot; and &quot;needs a database row per user&quot; aren&#39;t the same problem.\u003C\u002Fstrong> If what you actually need is data that survives across a user&#39;s many requests (not just within one), none of these three directives is the tool — that&#39;s your own data layer, read directly or behind a conventional cache.",{"id":305,"html":306,"text":306,"type":135,"level":31},"b43","Best practices",{"id":308,"type":141,"items":309,"ordered":18},"b44",[310,311,312,313,314],"Default to plain \u003Ccode>use cache\u003C\u002Fcode> for anything that&#39;s genuinely identical for every visitor. It&#39;s the cheapest of the three — no extra infrastructure, and it&#39;s eligible for the static shell.","Reach for \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> only once you&#39;ve confirmed the dimension you&#39;re caching on has low cardinality (a handful of currencies or categories, not one value per user) and the operation is slow or rate-limited enough to justify a network round trip to check.","Reach for \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode> only for data that&#39;s genuinely personal and either can&#39;t be refactored to read runtime values outside the cached scope, or has a real compliance reason it must never land in a shared store — the docs call this the narrow case, not the default.","Before adding any directive, ask whether the runtime value can simply be read \u003Cem>outside\u003C\u002Fem> the cached function and passed in as an argument. That&#39;s the preferred pattern for both \u003Ccode>use cache\u003C\u002Fcode> and \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode>, and it often removes the need for \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode> entirely.","Set an explicit \u003Ccode>cacheLife\u003C\u002Fcode> on every cache you write. The implicit \u003Ccode>default\u003C\u002Fcode> profile (5 minutes client-side stale, 15 minutes server-side revalidate) is a reasonable fallback, but it hides the lifetime at the call site — and for private caches specifically, forgetting it means forgetting to decide whether this function should shorten the whole route&#39;s client stale time.",{"id":316,"html":317,"type":124},"b45","\u003C!-- playground:start -->",{"id":319,"html":320,"text":320,"type":135,"level":31},"b46","🎮 Try it yourself",{"id":322,"html":323,"type":124},"b47","\u003Cp>\u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-use-cache-remote-vs-private\u002Fplayground\">▶️ Open the interactive playground →\u003C\u002Fa>\u003C\u002Fstrong>\u003C\u002Fp>",{"id":325,"html":326,"type":124},"b48","\u003Cp>\u003Cem>Runs right in your browser — poke at it and watch the concept react live.\u003C\u002Fem>\u003C\u002Fp>",{"id":328,"html":329,"type":124},"b49","\u003C!-- playground:end -->",{"id":331,"html":332,"text":332,"type":135,"level":31},"b50","Key takeaways",{"id":334,"type":141,"items":335,"ordered":18},"b51",[336,337,338,339,340],"\u003Ccode>use cache\u003C\u002Fcode>, \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode>, and \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> answer three different questions — shared\u002Fdurable, personal\u002Fephemeral, and shared\u002Fdurable-but-deferred — not three strengths of the same cache.","\u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode> lets you read \u003Ccode>cookies()\u003C\u002Fcode>, \u003Ccode>headers()\u003C\u002Fcode>, and \u003Ccode>searchParams\u003C\u002Fcode> inside a cached scope, but in production it never persists past the request that created it. It solves an \u003Cem>access\u003C\u002Fem> problem, not a \u003Cem>sharing\u003C\u002Fem> problem.","\u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> solves the opposite problem: it shares a cache entry across every server instance, using a real handler, at the cost of infrastructure and network latency — and it only pays off when the cached dimension has few distinct values relative to your traffic.","Remote and private caches cannot nest inside each other in either direction, because their guarantees are mutually exclusive.","The cheapest fix for &quot;I need runtime data in a cached function&quot; is still reading it outside the cache and passing it as an argument — reach for \u003Ccode>private\u003C\u002Fcode> or \u003Ccode>remote\u003C\u002Fcode> only once that&#39;s genuinely not an option.",{"id":342,"html":343,"type":124},"b52","\u003Cp>That team from the opening: the actual fix wasn&#39;t choosing between \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode> and \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> for the pricing function — it was recognizing that currency isn&#39;t personal data at all. The recommendations stayed on \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode>, keyed per session, exactly as personal data should be. The price moved to \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode>, keyed on currency — a few dozen cache entries instead of one cache miss per visitor, and their pricing API went back to seeing the traffic it was built for.\u003C\u002Fp>",{"id":345,"html":346,"type":124},"b53","\u003C!-- quiz:start -->",{"id":348,"html":349,"text":349,"type":135,"level":31},"b54","🧠 Test yourself",{"id":351,"html":352,"type":124},"b55","\u003Cp>Think it clicked? \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-use-cache-remote-vs-private\u002Fquiz\">Take the 8-question quiz →\u003C\u002Fa>\u003C\u002Fstrong>\u003C\u002Fp>",{"id":354,"html":355,"type":124},"b56","\u003Cp>\u003Cem>Instant feedback, a hint on every question, and an explanation for each answer — right or wrong.\u003C\u002Fem>\u003C\u002Fp>",{"id":357,"html":358,"type":124},"b57","\u003C!-- quiz:end -->",{"id":360,"html":361,"text":361,"type":135,"level":31},"b58","FAQ",{"id":363,"html":364,"text":365,"type":135,"level":43},"b59","Can I use \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> and \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode> together?","Can I use 'use cache: remote' and 'use cache: private' together?",{"id":367,"html":368,"type":124},"b60","\u003Cp>Not nested inside one another, in either direction — Next.js rejects that at the boundary. You can use both in the same route, on different functions, as the pricing-and-recommendations example above does; you just can&#39;t wrap one directive&#39;s scope inside the other&#39;s.\u003C\u002Fp>",{"id":370,"html":371,"text":372,"type":135,"level":43},"b61","Does \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> persist across deployments?","Does 'use cache: remote' persist across deployments?",{"id":374,"html":375,"type":124},"b62","\u003Cp>No. Its cache key includes your build ID (or \u003Ccode>deploymentId\u003C\u002Fcode> if configured), so every new deploy invalidates every entry by construction. If you need data that survives a deploy, that&#39;s a job for \u003Ccode>unstable_cache\u003C\u002Fcode> (for non-\u003Ccode>fetch\u003C\u002Fcode> functions) or the \u003Ccode>fetch\u003C\u002Fcode> cache, not either of today&#39;s two directives.\u003C\u002Fp>",{"id":377,"html":378,"text":379,"type":135,"level":43},"b63","Why doesn&#39;t my \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode> data show up for a different request?","Why doesn't my 'use cache: private' data show up for a different request?",{"id":381,"html":382,"type":124},"b64","\u003Cp>Because that&#39;s the entire point of the directive. It isn&#39;t a bug or a cold-cache miss — \u003Ccode>&#39;use cache: private&#39;\u003C\u002Fcode> is explicitly designed to never share its result across requests in production. If you need the same computed value available to a second request, you want \u003Ccode>use cache\u003C\u002Fcode> or \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> instead, with the request-specific part extracted and passed in as a plain argument.\u003C\u002Fp>",{"id":384,"html":385,"text":386,"type":135,"level":43},"b65","How is \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode> different from \u003Ccode>unstable_cache()\u003C\u002Fcode>?","How is 'use cache: remote' different from unstablecache()?",{"id":388,"html":389,"type":124},"b66","\u003Cp>Both can persist data outside the in-memory default, but they come from different eras of the same problem. \u003Ccode>unstable_cache()\u003C\u002Fcode> predates Cache Components, has its own key-building rules (notably, no awareness of root params), and the docs now point most use cases toward \u003Ccode>use cache\u003C\u002Fcode> and its Cache-Components-era siblings instead. If you&#39;re still using \u003Ccode>unstable_cache()\u003C\u002Fcode> for something that could be a cached function today, \u003Ca href=\"https:\u002F\u002Fdev.to\u002Fparsajiravand\u002Fnextjs-1645-how-unstablecache-leaked-data-across-root-params-1om0\">a cold-start cache-key leak between the two is worth reading about\u003C\u002Fa> before you decide which one to keep.\u003C\u002Fp>",{"id":391,"html":392,"text":393,"type":135,"level":43},"b67","Do I have to set up \u003Ccode>cacheHandlers\u003C\u002Fcode> myself to use \u003Ccode>&#39;use cache: remote&#39;\u003C\u002Fcode>?","Do I have to set up cacheHandlers myself to use 'use cache: remote'?",{"id":395,"html":396,"type":124},"b68","\u003Cp>Usually not — most hosting providers wire up a default remote handler for you. You only need to configure \u003Ccode>cacheHandlers\u003C\u002Fcode> yourself if you&#39;re self-hosting and want remote caching, or if you want to swap in a specific store (Redis, a particular KV service) instead of whatever your platform provides by default.\u003C\u002Fp>",{"id":398,"html":399,"text":400,"type":135,"level":43},"b69","What happens if I forget \u003Ccode>cacheLife\u003C\u002Fcode> on a private or remote cache?","What happens if I forget cacheLife on a private or remote cache?",{"id":402,"html":403,"type":124},"b70","\u003Cp>The implicit \u003Ccode>default\u003C\u002Fcode> profile applies: 5 minutes \u003Ccode>stale\u003C\u002Fcode> (client-side), 15 minutes \u003Ccode>revalidate\u003C\u002Fcode> (server-side), and no time-based \u003Ccode>expire\u003C\u002Fcode>. It&#39;s a safe fallback, but for a private cache specifically, it also means you haven&#39;t deliberately decided whether this function should be allowed to shorten the whole route&#39;s client-side stale time — set it explicitly once you know the answer.\u003C\u002Fp>",{"id":405,"html":406,"text":406,"type":135,"level":31},"b71","Cheat sheet",{"id":408,"code":409,"type":228,"language":410,"highlight":411},"b72","NEXT.JS 16 CACHE DIRECTIVES — WHICH ONE?\n\n                         use cache     use cache: remote   use cache: private\nShared across users?       yes              yes                  no\nCan read cookies\u002Fheaders?  no               no                   yes\nWhere it's stored          in-memory*       remote handler       nowhere durable\nSurvives a deploy?         no               no                   n\u002Fa\nNeeds cacheHandlers?       optional         yes (or platform)    not configurable\nContributes to static shell? yes            when static          never\n\n* or a configured handler — see cacheHandlers\n\nDECISION ORDER (ask in this order, stop at the first \"yes\"):\n1. Can I read the runtime value OUTSIDE the cache and pass it in as an argument?\n   → yes: use plain `use cache`. Done — you probably don't need private or remote.\n2. Is the value genuinely personal \u002F per-user, with no low-cardinality dimension\n   to cache on instead?\n   → yes: `use cache: private`. Set cacheLife({ stale: Infinity }) if it's pure\n     within-request dedup and shouldn't shorten the route's client stale time.\n3. Is the value shared across many users, deferred to request time, and worth\n   paying infra + latency for a real cache hit (slow\u002Frate-limited\u002Fexpensive)?\n   → yes: `use cache: remote`, keyed on the LOW-cardinality dimension\n     (currency, locale, category) — never on something unique per request.\n4. Otherwise: plain `use cache` with an explicit cacheLife.\n\nNESTING\n  remote  inside remote   -> OK\n  remote  inside use cache -> OK\n  remote  inside private   -> ERROR\n  private inside remote    -> ERROR\n\nnext.config.ts (required for all three)\n  export default {\n    cacheComponents: true,\n  }","text",[],{"id":413,"html":414,"type":124},"b73","\u003C!-- related:start -->",{"id":416,"html":417,"text":417,"type":135,"level":31},"b74","📚 Read next",{"id":419,"type":141,"items":420,"ordered":18},"b75",[421,422,423],"\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-cache-components-explained\">Next.js Cache Components Explained (with Cheat Sheet)\u003C\u002Fa>","\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-unstable-cache-root-params-leak\">Next.js 16.4.5: How unstable_cache Leaked Data Across Root Params\u003C\u002Fa>","\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-middleware-to-proxy-network-boundary\">Next.js proxy.ts Explained (with Cheat Sheet)\u003C\u002Fa>",{"id":425,"html":426,"type":124},"b76","\u003C!-- related:end -->",{"id":428,"type":429},"b77","divider",{"id":431,"html":432,"type":124},"b78","\u003Cp>🚀 \u003Cstrong>Want more like this?\u003C\u002Fstrong> Every guide, playground, and quiz lives on \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002F\">bestpractic.org\u003C\u002Fa>\u003C\u002Fstrong> — open it and \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002F\">sign up free\u003C\u002Fa>\u003C\u002Fstrong> so the next one finds you.\u003C\u002Fp>",{"id":434,"html":435,"type":124},"b79","\u003Cp>\u003Cem>Thanks for reading! Let&#39;s stay connected:\u003C\u002Fem>\u003C\u002Fp>",{"id":437,"type":141,"items":438,"ordered":18},"b80",[439,440,441],"⭐ \u003Cstrong>GitHub\u003C\u002Fstrong> — follow me and star the projects: \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fparsajiravand\">github.com\u002Fparsajiravand\u003C\u002Fa>","💬 \u003Cstrong>Discord\u003C\u002Fstrong> — join the frontend best-practices community: \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002Fd9KRhuAwQ\">discord.gg\u002Fd9KRhuAwQ\u003C\u002Fa>","📸 \u003Cstrong>Instagram\u003C\u002Fstrong> — frontend best practices, daily: \u003Ca href=\"https:\u002F\u002Fwww.instagram.com\u002Fbestpractice___\u002F\">@bestpractice___\u003C\u002Fa>","A team ships personalized product recommendations on a product page. The data depends on the visitor's session cookie, so a teammate wraps the fetch in a plain `'use cache'` function and reads `cookies()` inside it. `next build` passes. `next start` doesn't: every request to that route throws `next-request-in-use-cache`, because `use cache` cannot see request-time APIs at all, by design.\n\nThe fix looks obvious: switch to `'use cache: private'`, since the docs say it's the directive that can read cookies. It compiles, it renders, the recommendations are personalized again — and the team, having just learned there's a \"private\" cache, applies it everywhere else that used to be a plain `fetch`, including the currency-converted price that's genuinely the same for every visitor paying in USD. Three weeks later, the pricing API is getting hammered on every cold start in production, because `'use cache: private'` was never meant to deduplicate shared data across users — it isn't that kind of cache at all.\n\nThis is the mix-up this article exists to prevent. Next.js 16 ships **three** caching directives under Cache Components — `use cache`, `'use cache: private'`, and `'use cache: remote'` — and they answer three different questions, not one question three ways. This article is written against **Next.js 16.4.6** (verified against the framework's own bundled documentation and npm's `latest` dist-tag in November 2026); both private and remote caches were introduced and stabilized together with Cache Components in Next.js 16.0.0.\n\n## What you'll learn\n\nBy the end of this article you'll be able to:\n\n- Explain what each of the three `use cache` directives actually stores, and where\n- Pick the right one for personalized data, for shared-but-expensive data, and for everything else\n- Read the nesting rules that decide which directives can wrap which\n- Avoid the two opposite mistakes: caching personal data where it could leak, and caching shared data where it never gets reused\n\n## Who this is for\n\nYou're already caching something with plain `'use cache'` — or you've read [Next.js Cache Components Explained](https:\u002F\u002Fdev.to\u002Fparsajiravand\u002Fnextjs-cache-components-explained-with-cheat-sheet-55ob), which builds that foundation from nothing. This article assumes that part and goes one level deeper, into the two directives that exist specifically for data `use cache` can't handle. You don't need to have read it first; the rules below stand on their own.\n\n## Table of contents\n\n- [The problem: one cache, three jobs it can't all do](#the-problem-one-cache-three-jobs-it-cant-all-do)\n- [The mental model: scope and storage are two different dials](#the-mental-model-scope-and-storage-are-two-different-dials)\n- [Stage 1: the baseline — what plain `use cache` won't do](#stage-1-the-baseline-what-plain-use-cache-wont-do)\n- [Stage 2: `use cache: private` — per-request, never shared](#stage-2-use-cache-private-per-request-never-shared)\n- [Stage 3: `use cache: remote` — shared across every instance](#stage-3-use-cache-remote-shared-across-every-instance)\n- [Stage 4: the nesting rules](#stage-4-the-nesting-rules)\n- [Edge cases and gotchas](#edge-cases-and-gotchas)\n- [Best practices](#best-practices)\n- [FAQ](#faq)\n- [Cheat sheet](#cheat-sheet)\n\n## The problem: one cache, three jobs it can't all do\n\nPlain `use cache` does two jobs at once: it tells Next.js what's safe to put in a route's prerendered **static shell**, and it caches a function's result so repeat calls with the same inputs skip the work. Both jobs assume the same thing — that the cached value is identical for every visitor who triggers the same inputs. That assumption breaks the moment a value depends on *who's asking*, which is exactly why `use cache` refuses to let you read `cookies()`, `headers()`, or `searchParams` inside it: there'd be no safe single value to put in a shell every visitor shares.\n\nSo the framework splits the \"who's asking\" problem into two separate directives, one for each half of it:\n\n- Sometimes the answer genuinely differs **per visitor** and must never be handed to anyone else — that's `'use cache: private'`.\n- Sometimes the answer is the same for **many** visitors (same currency, same language, same product category) but you still need to defer reading it until request time, and the default in-memory cache isn't durable enough across your server instances — that's `'use cache: remote'`.\n\nNeither one is \"the private version\" or \"the bigger version\" of the other. They answer different questions, and reaching for the wrong one either leaks nothing useful (over-caching data that was never personal) or hammers your backend (under-caching data that should have been shared).\n\n## The mental model: scope and storage are two different dials\n\n**The mental model:** every cache in Next.js is the product of two independent choices — who the cached value is allowed to be *shared with* (scope), and *where it physically lives* (storage). Conflating these two dials is the whole source of confusion here.\n\n| | `use cache` | `'use cache: remote'` | `'use cache: private'` |\n|---|---|---|---|\n| **Scope** — who shares one entry | Everyone | Everyone | Nobody but this one request |\n| **Storage** — where it lives | In-memory (or a configured handler) | A remote cache handler (Redis, KV, …) | Nowhere persistent — not saved across requests in production |\n| **Can read `cookies()` \u002F `headers()`** | No | No | Yes |\n\nRead the table by column, not by row: `use cache` and `'use cache: remote'` share the same scope (everyone) and differ only in storage durability. `'use cache: private'` is the odd one out on scope — it exists purely to let request-specific code participate in caching at all, and the tradeoff for that access is that nothing it produces gets saved across requests.\n\n## Stage 1: the baseline — what plain `use cache` won't do\n\nA quick recap, since both of today's directives are defined by contrast to this one. A plain cached function looks like this:\n\n```ts\n\u002F\u002F app\u002Flib\u002Fpricing.ts\nimport { cacheLife } from 'next\u002Fcache';\n\nexport async function getBasePrice(productId: string) {\n  'use cache';\n  cacheLife('hours');\n  return db.products.getPrice(productId);\n}\n```\n\nThis is shared across every visitor who asks for the same `productId`, and it can contribute to the route's static shell. The constraint: this function, and anything it calls, cannot touch `cookies()`, `headers()`, or `searchParams` — doing so throws `next-request-in-use-cache` the moment the route actually runs, even though `next build` may not have caught it.\n\n**Key concept:** `use cache` isn't refusing to be \"dynamic\" out of caution — it genuinely has nowhere safe to put a per-visitor answer. That gap is exactly what the next two directives exist to fill, each for a different reason.\n\n## Stage 2: `use cache: private` — per-request, never shared\n\n`'use cache: private'` lifts the ban on request-time APIs, at the cost of never sharing the result:\n\n```tsx\n\u002F\u002F app\u002Fproduct\u002F[id]\u002Fpage.tsx\nimport { Suspense } from 'react';\nimport { cookies } from 'next\u002Fheaders';\nimport { cacheLife, cacheTag } from 'next\u002Fcache';\n\nexport default async function ProductPage({ params }: { params: Promise\u003C{ id: string }> }) {\n  const { id } = await params;\n  return (\n    \u003CSuspense fallback={\u003Cdiv>Loading recommendations...\u003C\u002Fdiv>}>\n      \u003CRecommendations productId={id} \u002F>\n    \u003C\u002FSuspense>\n  );\n}\n\nasync function Recommendations({ productId }: { productId: string }) {\n  const sessionId = (await cookies()).get('session-id')?.value ?? 'guest';\n  const recs = await getRecommendations(productId, sessionId);\n  return \u003CRecList items={recs} \u002F>;\n}\n\nasync function getRecommendations(productId: string, sessionId: string) {\n  'use cache: private';\n  cacheTag(`recommendations-${productId}`);\n  cacheLife({ stale: 60 });\n  return db.recommendations.personalize(productId, sessionId);\n}\n```\n\nIn production, calling this function twice *within the same request* can reuse the result — that's request-scoped deduplication, not a server cache. It is never written to a cache that a later request, from the same visitor or anyone else, can read. In development, Next.js does keep it in memory, keyed by that request's cookies and headers, so you can watch it serve a near-identical dev request from cache — which is useful for iterating locally, but isn't the production behavior.\n\n**Key concept:** the `stale` time you set with `cacheLife` governs the *client-side* router cache, not a server store. Private cache functions are excluded from static-shell generation entirely, so this value only controls how long the browser can reuse what it already streamed down. The docs call out a specific threshold: `stale` must be at least 30 seconds for per-link prefetching to work, and at least 5 minutes for the content to be eligible for the route's App Shell. If a function only needs within-request dedup and shouldn't shorten the route's overall client stale time, set `cacheLife({ stale: Infinity })` — that opts it out of influencing the route's shortest stale time without claiming server persistence it was never going to get.\n\n## Stage 3: `use cache: remote` — shared across every instance\n\n`'use cache: remote'` solves a completely different problem: `use cache`'s default in-memory store is just that — in-memory, per instance. In a serverless deployment, each invocation can land on a different, short-lived instance, so the in-memory cache barely helps; every cold instance re-runs the work and re-hits your backend.\n\n```tsx\n\u002F\u002F app\u002Fproduct\u002F[id]\u002Fpage.tsx\nimport { Suspense } from 'react';\nimport { cookies } from 'next\u002Fheaders';\nimport { cacheTag, cacheLife } from 'next\u002Fcache';\n\nasync function ProductPrice({ productId }: { productId: string }) {\n  \u002F\u002F Reading cookies defers this component to request time\n  const currency = (await cookies()).get('currency')?.value ?? 'USD';\n  const price = await getProductPrice(productId, currency);\n  return \u003Cdiv>Price: {price} {currency}\u003C\u002Fdiv>;\n}\n\nasync function getProductPrice(productId: string, currency: string) {\n  'use cache: remote';\n  cacheTag(`product-price-${productId}`);\n  cacheLife({ expire: 3600 }); \u002F\u002F 1 hour\n\n  \u002F\u002F Cached per (productId, currency) — a handful of currencies, not one entry per visitor\n  return db.products.getPrice(productId, currency);\n}\n```\n\nNotice what's `'use cache: remote'`, not `'use cache: private'`, in this example: the price depends on `currency`, which is read from a cookie, but currency is shared across potentially thousands of visitors. Caching it as \"private\" would create one cache miss per visitor for data that's identical across a whole currency; caching it as \"remote\" creates one shared entry per currency and lets every server instance hit that same entry.\n\nA remote cache needs a real handler — Redis, a KV store, anything configured through [`cacheHandlers`](https:\u002F\u002Fnextjs.org\u002Fdocs\u002Fapp\u002Fapi-reference\u002Fconfig\u002Fnext-config-js\u002FcacheHandlers) — which most hosting providers supply automatically, and which you configure yourself if you're self-hosting. That's the tradeoff `'use cache: remote'` is explicit about: infrastructure cost and a network round trip on every lookup, in exchange for a cache that's actually shared once a request falls outside the static shell.\n\n**Key concept:** reach for `'use cache: remote'` only when the dimension you're caching on has *few* distinct values relative to your traffic (currencies, languages, categories — not user IDs or arbitrary search filters). The docs frame this as finding \"the dimension with fewer unique values\" and caching on that, then filtering the rest in memory. Cache on `category`, not on `category + minPrice`, and the hit rate difference is the entire point of paying for a remote handler at all.\n\n## Stage 4: the nesting rules\n\nBecause remote and private caches solve opposite problems, Next.js enforces where each can appear relative to the other:\n\n- A remote cache **can** nest inside another remote cache, or inside a plain `use cache`.\n- A remote cache **cannot** nest inside a private cache, in either direction.\n\n```tsx\n\u002F\u002F VALID — remote inside a plain cache\nasync function outerCache() {\n  'use cache';\n  return innerRemote(); \u002F\u002F fine — resolved when deferred to request time\n}\n\n\u002F\u002F INVALID — remote inside private, or private inside remote, throws\nasync function outerPrivate() {\n  'use cache: private';\n  return innerRemote(); \u002F\u002F Error\n}\n```\n\nThe rule follows directly from the mental model: a private cache's entire contract is \"nothing here gets shared.\" Letting a shared remote cache live inside it (or vice versa) would mean one of the two guarantees has to break. Next.js enforces the rule at the boundary instead of leaving it to be discovered in production.\n\n## Edge cases and gotchas\n\n- **Remote caches don't survive a deploy.** The cache key for `'use cache: remote'` includes your build ID (or `deploymentId`, if you've configured one), so a new build produces entirely new keys. This is intentional — a refactored function or an upgraded dependency can quietly change what a cache entry means, and reusing an old entry under a new build risks serving data that doesn't match what the new code expects.\n- **Draft Mode bypasses `use cache`, no special case needed.** The docs are explicit about plain `use cache`: with Draft Mode enabled, cached functions and components re-execute on every request and their results aren't saved to the cache. `'use cache: private'` already never persists across requests in production, so Draft Mode doesn't change anything there either way. The docs don't make the same statement by name for `'use cache: remote'` — don't assume it behaves identically without checking your own cache handler.\n- **`connection()` is off-limits in both `use cache` and `'use cache: private'`.** It's easy to assume \"private\" means \"anything request-related is now fair game,\" but `connection()` specifically carries connection-level information that isn't safe to cache even per-request, so it stays prohibited in both.\n- **You can't configure a custom handler for `'use cache: private'`.** Unlike `use cache` and `'use cache: remote'`, there's no `cacheHandlers` hook for the private directive — by design, since it's defined by *not* persisting anywhere durable.\n- **\"Private\" and \"needs a database row per user\" aren't the same problem.** If what you actually need is data that survives across a user's many requests (not just within one), none of these three directives is the tool — that's your own data layer, read directly or behind a conventional cache.\n\n## Best practices\n\n- Default to plain `use cache` for anything that's genuinely identical for every visitor. It's the cheapest of the three — no extra infrastructure, and it's eligible for the static shell.\n- Reach for `'use cache: remote'` only once you've confirmed the dimension you're caching on has low cardinality (a handful of currencies or categories, not one value per user) and the operation is slow or rate-limited enough to justify a network round trip to check.\n- Reach for `'use cache: private'` only for data that's genuinely personal and either can't be refactored to read runtime values outside the cached scope, or has a real compliance reason it must never land in a shared store — the docs call this the narrow case, not the default.\n- Before adding any directive, ask whether the runtime value can simply be read *outside* the cached function and passed in as an argument. That's the preferred pattern for both `use cache` and `'use cache: remote'`, and it often removes the need for `'use cache: private'` entirely.\n- Set an explicit `cacheLife` on every cache you write. The implicit `default` profile (5 minutes client-side stale, 15 minutes server-side revalidate) is a reasonable fallback, but it hides the lifetime at the call site — and for private caches specifically, forgetting it means forgetting to decide whether this function should shorten the whole route's client stale time.\n\n\u003C!-- playground:start -->\n\n## 🎮 Try it yourself\n\n**[▶️ Open the interactive playground →](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-use-cache-remote-vs-private\u002Fplayground)**\n\n_Runs right in your browser — poke at it and watch the concept react live._\n\n\u003C!-- playground:end -->\n\n## Key takeaways\n\n- `use cache`, `'use cache: private'`, and `'use cache: remote'` answer three different questions — shared\u002Fdurable, personal\u002Fephemeral, and shared\u002Fdurable-but-deferred — not three strengths of the same cache.\n- `'use cache: private'` lets you read `cookies()`, `headers()`, and `searchParams` inside a cached scope, but in production it never persists past the request that created it. It solves an *access* problem, not a *sharing* problem.\n- `'use cache: remote'` solves the opposite problem: it shares a cache entry across every server instance, using a real handler, at the cost of infrastructure and network latency — and it only pays off when the cached dimension has few distinct values relative to your traffic.\n- Remote and private caches cannot nest inside each other in either direction, because their guarantees are mutually exclusive.\n- The cheapest fix for \"I need runtime data in a cached function\" is still reading it outside the cache and passing it as an argument — reach for `private` or `remote` only once that's genuinely not an option.\n\nThat team from the opening: the actual fix wasn't choosing between `'use cache: private'` and `'use cache: remote'` for the pricing function — it was recognizing that currency isn't personal data at all. The recommendations stayed on `'use cache: private'`, keyed per session, exactly as personal data should be. The price moved to `'use cache: remote'`, keyed on currency — a few dozen cache entries instead of one cache miss per visitor, and their pricing API went back to seeing the traffic it was built for.\n\n\u003C!-- quiz:start -->\n\n## 🧠 Test yourself\n\nThink it clicked? **[Take the 8-question quiz →](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-use-cache-remote-vs-private\u002Fquiz)**\n\n_Instant feedback, a hint on every question, and an explanation for each answer — right or wrong._\n\n\u003C!-- quiz:end -->\n\n## FAQ\n\n### Can I use `'use cache: remote'` and `'use cache: private'` together?\n\nNot nested inside one another, in either direction — Next.js rejects that at the boundary. You can use both in the same route, on different functions, as the pricing-and-recommendations example above does; you just can't wrap one directive's scope inside the other's.\n\n### Does `'use cache: remote'` persist across deployments?\n\nNo. Its cache key includes your build ID (or `deploymentId` if configured), so every new deploy invalidates every entry by construction. If you need data that survives a deploy, that's a job for `unstable_cache` (for non-`fetch` functions) or the `fetch` cache, not either of today's two directives.\n\n### Why doesn't my `'use cache: private'` data show up for a different request?\n\nBecause that's the entire point of the directive. It isn't a bug or a cold-cache miss — `'use cache: private'` is explicitly designed to never share its result across requests in production. If you need the same computed value available to a second request, you want `use cache` or `'use cache: remote'` instead, with the request-specific part extracted and passed in as a plain argument.\n\n### How is `'use cache: remote'` different from `unstable_cache()`?\n\nBoth can persist data outside the in-memory default, but they come from different eras of the same problem. `unstable_cache()` predates Cache Components, has its own key-building rules (notably, no awareness of root params), and the docs now point most use cases toward `use cache` and its Cache-Components-era siblings instead. If you're still using `unstable_cache()` for something that could be a cached function today, [a cold-start cache-key leak between the two is worth reading about](https:\u002F\u002Fdev.to\u002Fparsajiravand\u002Fnextjs-1645-how-unstablecache-leaked-data-across-root-params-1om0) before you decide which one to keep.\n\n### Do I have to set up `cacheHandlers` myself to use `'use cache: remote'`?\n\nUsually not — most hosting providers wire up a default remote handler for you. You only need to configure `cacheHandlers` yourself if you're self-hosting and want remote caching, or if you want to swap in a specific store (Redis, a particular KV service) instead of whatever your platform provides by default.\n\n### What happens if I forget `cacheLife` on a private or remote cache?\n\nThe implicit `default` profile applies: 5 minutes `stale` (client-side), 15 minutes `revalidate` (server-side), and no time-based `expire`. It's a safe fallback, but for a private cache specifically, it also means you haven't deliberately decided whether this function should be allowed to shorten the whole route's client-side stale time — set it explicitly once you know the answer.\n\n## Cheat sheet\n\n```text\nNEXT.JS 16 CACHE DIRECTIVES — WHICH ONE?\n\n                         use cache     use cache: remote   use cache: private\nShared across users?       yes              yes                  no\nCan read cookies\u002Fheaders?  no               no                   yes\nWhere it's stored          in-memory*       remote handler       nowhere durable\nSurvives a deploy?         no               no                   n\u002Fa\nNeeds cacheHandlers?       optional         yes (or platform)    not configurable\nContributes to static shell? yes            when static          never\n\n* or a configured handler — see cacheHandlers\n\nDECISION ORDER (ask in this order, stop at the first \"yes\"):\n1. Can I read the runtime value OUTSIDE the cache and pass it in as an argument?\n   → yes: use plain `use cache`. Done — you probably don't need private or remote.\n2. Is the value genuinely personal \u002F per-user, with no low-cardinality dimension\n   to cache on instead?\n   → yes: `use cache: private`. Set cacheLife({ stale: Infinity }) if it's pure\n     within-request dedup and shouldn't shorten the route's client stale time.\n3. Is the value shared across many users, deferred to request time, and worth\n   paying infra + latency for a real cache hit (slow\u002Frate-limited\u002Fexpensive)?\n   → yes: `use cache: remote`, keyed on the LOW-cardinality dimension\n     (currency, locale, category) — never on something unique per request.\n4. Otherwise: plain `use cache` with an explicit cacheLife.\n\nNESTING\n  remote  inside remote   -> OK\n  remote  inside use cache -> OK\n  remote  inside private   -> ERROR\n  private inside remote    -> ERROR\n\nnext.config.ts (required for all three)\n  export default {\n    cacheComponents: true,\n  }\n```\n\n\u003C!-- related:start -->\n\n## 📚 Read next\n\n- [Next.js Cache Components Explained (with Cheat Sheet)](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-cache-components-explained)\n- [Next.js 16.4.5: How unstable_cache Leaked Data Across Root Params](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-unstable-cache-root-params-leak)\n- [Next.js proxy.ts Explained (with Cheat Sheet)](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-middleware-to-proxy-network-boundary)\n\n\u003C!-- related:end -->\n\n---\n\n🚀 **Want more like this?** Every guide, playground, and quiz lives on **[bestpractic.org](https:\u002F\u002Fbestpractic.org\u002F)** — open it and **[sign up free](https:\u002F\u002Fbestpractic.org\u002F)** so the next one finds you.\n\n*Thanks for reading! Let's stay connected:*\n\n- ⭐ **GitHub** — follow me and star the projects: [github.com\u002Fparsajiravand](https:\u002F\u002Fgithub.com\u002Fparsajiravand)\n- 💬 **Discord** — join the frontend best-practices community: [discord.gg\u002Fd9KRhuAwQ](https:\u002F\u002Fdiscord.gg\u002Fd9KRhuAwQ)\n- 📸 **Instagram** — frontend best practices, daily: [@bestpractice___](https:\u002F\u002Fwww.instagram.com\u002Fbestpractice___\u002F)",{"title":96,"canonical":444,"description":98},"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fnextjs-weekly-use-cache-remote-vs-private","01a1fce0-ce77-75f1-af57-e6d46d410a66",{"name":447,"part":92,"total":92,"items":448},"Next.js Deep Dive",[449,454,459,463,468,472,476,480,484,488,492,496,500],{"slug":450,"title":451,"publishedAt":452,"readingMinutes":453},"nextjs-weekly-cache-components-explained","Next.js Cache Components Explained (with Cheat Sheet)","2026-09-01T11:24:15.087Z",14,{"slug":455,"title":456,"publishedAt":457,"readingMinutes":458},"nextjs-weekly-server-actions-mutations-security","Next.js Server Actions: Mutations & Security (Cheat Sheet)","2026-09-08T10:57:00.975Z",15,{"slug":460,"title":461,"publishedAt":462,"readingMinutes":453},"nextjs-weekly-parallel-intercepting-routes-modals","Next.js Parallel & Intercepting Routes: Modals Done Right","2026-09-15T17:50:47.218Z",{"slug":464,"title":465,"publishedAt":466,"readingMinutes":467},"nextjs-weekly-middleware-to-proxy-network-boundary","Next.js proxy.ts Explained (with Cheat Sheet)","2026-09-22T19:36:08.416Z",12,{"slug":469,"title":470,"publishedAt":471,"readingMinutes":458},"nextjs-weekly-route-handlers-caching-streaming","Next.js Route Handlers: GET Stopped Caching in 15 — How to Cache in 16","2026-09-29T09:16:08.176Z",{"slug":473,"title":474,"publishedAt":475,"readingMinutes":453},"nextjs-weekly-streaming-metadata-head","Next.js Streaming Metadata: Why Your `\u003Chead>` Looks Incomplete","2026-10-06T06:10:31.468Z",{"slug":477,"title":478,"publishedAt":479,"readingMinutes":458},"nextjs-weekly-image-priority-quality-changes","Next.js 16 Image: priority Deprecated, quality Now Allowlisted","2026-10-13T06:10:29.815Z",{"slug":481,"title":482,"publishedAt":483,"readingMinutes":453},"nextjs-weekly-instant-navigations-partial-prefetching","Next.js 16.3 Instant Navigations: How Partial Prefetching Works","2026-10-20T06:10:59.936Z",{"slug":485,"title":486,"publishedAt":487,"readingMinutes":453},"nextjs-weekly-updatetag-vs-revalidatetag","Next.js 16 updateTag vs revalidateTag: What Changed","2026-10-27T06:11:02.727Z",{"slug":489,"title":490,"publishedAt":491,"readingMinutes":92},"nextjs-weekly-ensurestatic-locks-static-output","Next.js 16.4 ensureStatic: Locking Routes Fully Static","2026-11-03T06:10:26.449Z",{"slug":493,"title":494,"publishedAt":495,"readingMinutes":92},"nextjs-weekly-unstable-cache-root-params-leak","Next.js 16.4.5: How unstable_cache Leaked Data Across Root Params","2026-11-10T20:39:47.146Z",{"slug":497,"title":498,"publishedAt":499,"readingMinutes":92},"nextjs-weekly-error-retry-vs-reset","Next.js 16.3 error.js: retry vs reset Aren't Interchangeable","2026-11-27T11:42:24.474Z",{"slug":95,"title":96,"publishedAt":101,"readingMinutes":100},{"id":502,"locked":18},"01a1fce0-d123-7193-adce-d5e91c3b4f0b",[504],{"id":505,"slug":95,"title":506,"_count":507},"01a1fce0-d15d-76be-8df1-33825470553d","Next.js use cache: remote vs use cache: private",{"questions":508},8,[510],{"locale":13,"slug":95},{"id":505,"slug":95,"title":506,"_count":512,"questionCount":508},{"questions":508},[],{"items":515,"meta":622},[516,528,543,562,577,592,607],{"id":94,"slug":95,"title":96,"subtitle":97,"excerpt":98,"coverUrl":99,"locale":13,"readingMinutes":100,"publishedAt":101,"viewCount":517,"likeCount":19,"commentCount":19,"author":518,"vertical":519,"topic":520,"tags":521,"_count":526,"playground":527,"hasQuiz":17,"hasPlayground":17},29,{"id":104,"name":105,"username":106,"avatarUrl":97,"headline":107},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":90,"name":91},[522,523,524,525],{"slug":90,"name":91,"color":97},{"slug":46,"name":47,"color":97},{"slug":58,"name":59,"color":97},{"slug":50,"name":51,"color":97},{"assessments":116},{"slug":95},{"id":529,"slug":497,"title":498,"subtitle":97,"excerpt":530,"coverUrl":531,"locale":13,"readingMinutes":92,"publishedAt":499,"viewCount":532,"likeCount":19,"commentCount":19,"author":533,"vertical":534,"topic":535,"tags":536,"_count":541,"playground":542,"hasQuiz":17,"hasPlayground":17},"01a1df1b-203c-7390-aa4a-3c6b678e7abe","Next.js 16.3 stabilized error.js's retry(), which re-fetches on recovery — reset() only clears state. The real difference, plus a copy-paste cheat sheet.","\u002Fmedia\u002Fcovers\u002Fnextjs-weekly-error-retry-vs-reset.png",10,{"id":104,"name":105,"username":106,"avatarUrl":97,"headline":107},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":90,"name":91},[537,538,539,540],{"slug":90,"name":91,"color":97},{"slug":78,"name":79,"color":97},{"slug":46,"name":47,"color":97},{"slug":58,"name":59,"color":97},{"assessments":116},{"slug":497},{"id":544,"slug":493,"title":494,"subtitle":97,"excerpt":545,"coverUrl":546,"locale":13,"readingMinutes":92,"publishedAt":495,"viewCount":547,"likeCount":19,"commentCount":19,"author":548,"vertical":549,"topic":550,"tags":551,"_count":560,"playground":561,"hasQuiz":17,"hasPlayground":17},"01a1b128-0d77-74cd-8d38-6dda8c5a843a","Next.js 16.4.5 patched a real bug: unstable_cache() could return another root param's cached data. Learn how cache keys work, plus a cheat sheet.","\u002Fmedia\u002Fcovers\u002Fnextjs-weekly-unstable-cache-root-params-leak.png",330,{"id":104,"name":105,"username":106,"avatarUrl":97,"headline":107},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":90,"name":91},[552,553,556,559],{"slug":90,"name":91,"color":97},{"slug":554,"name":555,"color":97},"security","Security",{"slug":557,"name":558,"color":97},"caching","Caching",{"slug":58,"name":59,"color":97},{"assessments":116},{"slug":493},{"id":563,"slug":489,"title":490,"subtitle":97,"excerpt":564,"coverUrl":565,"locale":13,"readingMinutes":92,"publishedAt":491,"viewCount":566,"likeCount":19,"commentCount":19,"author":567,"vertical":568,"topic":569,"tags":570,"_count":575,"playground":576,"hasQuiz":17,"hasPlayground":17},"01a1972e-c476-72af-9154-03327c89a57d","Next.js 16.4 stabilizes ensureStatic: lock a route's shell, prefetch, or full navigation to static output at build time, with a copy-paste cheat sheet.","\u002Fmedia\u002Fcovers\u002Fnextjs-weekly-ensurestatic-locks-static-output.png",361,{"id":104,"name":105,"username":106,"avatarUrl":97,"headline":107},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":90,"name":91},[571,572,573,574],{"slug":90,"name":91,"color":97},{"slug":557,"name":558,"color":97},{"slug":46,"name":47,"color":97},{"slug":58,"name":59,"color":97},{"assessments":116},{"slug":489},{"id":578,"slug":485,"title":486,"subtitle":97,"excerpt":579,"coverUrl":580,"locale":13,"readingMinutes":453,"publishedAt":487,"viewCount":581,"likeCount":19,"commentCount":19,"author":582,"vertical":583,"topic":584,"tags":585,"_count":590,"playground":591,"hasQuiz":17,"hasPlayground":17},"01a1749f-19a5-768a-82af-f3b8236ad42b","Next.js 16 deprecated revalidateTag's single-argument call and added updateTag. What the new profile argument changes, plus a copy-paste cheat sheet.","\u002Fmedia\u002Fcovers\u002Fnextjs-weekly-updatetag-vs-revalidatetag.png",459,{"id":104,"name":105,"username":106,"avatarUrl":97,"headline":107},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":90,"name":91},[586,587,588,589],{"slug":90,"name":91,"color":97},{"slug":557,"name":558,"color":97},{"slug":46,"name":47,"color":97},{"slug":58,"name":59,"color":97},{"assessments":116},{"slug":485},{"id":593,"slug":481,"title":482,"subtitle":97,"excerpt":594,"coverUrl":595,"locale":13,"readingMinutes":453,"publishedAt":483,"viewCount":596,"likeCount":19,"commentCount":19,"author":597,"vertical":598,"topic":599,"tags":600,"_count":605,"playground":606,"hasQuiz":17,"hasPlayground":17},"01a149cb-68e6-773f-bbbb-fce803732119","Next.js 16.3 shipped Instant Navigations: Partial Prefetching plus the App Shell. Learn the model, the Suspense gotcha, and a copy-paste cheat sheet.","\u002Fmedia\u002Fcovers\u002Fnextjs-weekly-instant-navigations-partial-prefetching.png",612,{"id":104,"name":105,"username":106,"avatarUrl":97,"headline":107},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":90,"name":91},[601,602,603,604],{"slug":90,"name":91,"color":97},{"slug":46,"name":47,"color":97},{"slug":58,"name":59,"color":97},{"slug":50,"name":51,"color":97},{"assessments":116},{"slug":481},{"id":608,"slug":477,"title":478,"subtitle":97,"excerpt":609,"coverUrl":610,"locale":13,"readingMinutes":458,"publishedAt":479,"viewCount":611,"likeCount":19,"commentCount":19,"author":612,"vertical":613,"topic":614,"tags":615,"_count":620,"playground":621,"hasQuiz":17,"hasPlayground":17},"01a120b9-d611-74ef-ad15-a267677c3251","Next.js 16 quietly deprecated Image's priority for preload and restricts quality to an allowlist (default: 75). What breaks, plus a copy-paste cheat sheet.","\u002Fmedia\u002Fcovers\u002Fnextjs-weekly-image-priority-quality-changes.png",852,{"id":104,"name":105,"username":106,"avatarUrl":97,"headline":107},{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":90,"name":91},[616,617,618,619],{"slug":90,"name":91,"color":97},{"slug":78,"name":79,"color":97},{"slug":46,"name":47,"color":97},{"slug":58,"name":59,"color":97},{"assessments":116},{"slug":477},{"page":116,"perPage":623,"total":92,"totalPages":31},7,"\u003Cdiv class=\"shj shj-lang-ts shj-multiline\" data-lang=\"ts\">\u003Cdiv class=\"shj-scroll\">\u003Cdiv class=\"shj-numbers\">\u003Cdiv>1\u003C\u002Fdiv>\u003Cdiv>2\u003C\u002Fdiv>\u003Cdiv>3\u003C\u002Fdiv>\u003Cdiv>4\u003C\u002Fdiv>\u003Cdiv>5\u003C\u002Fdiv>\u003Cdiv>6\u003C\u002Fdiv>\u003Cdiv>7\u003C\u002Fdiv>\u003Cdiv>8\u003C\u002Fdiv>\u003C\u002Fdiv>\u003Cdiv class=\"shj-code\">\u003Cspan class=\"shj-cmnt\">\u002F\u002F app\u002Flib\u002Fpricing.ts\n\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">import\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> cacheLife \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">from\u003C\u002Fspan> \u003Cspan class=\"shj-str\">'next\u002Fcache'\u003C\u002Fspan>;\n\n\u003Cspan class=\"shj-kwd\">export\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">async\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">function\u003C\u002Fspan> \u003Cspan class=\"shj-func\">getBasePrice\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>productId\u003Cspan class=\"shj-type\">: string\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-str\">'use cache'\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-func\">cacheLife\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-str\">'hours'\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-kwd\">return\u003C\u002Fspan> db\u003Cspan class=\"shj-oper\">.\u003C\u002Fspan>products\u003Cspan class=\"shj-oper\">.\u003C\u002Fspan>\u003Cspan class=\"shj-func\">getPrice\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>productId\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003C\u002Fdiv>\u003C\u002Fdiv>\u003C\u002Fdiv>","\u003Cdiv class=\"shj shj-lang-tsx shj-multiline\" data-lang=\"tsx\">\u003Cdiv class=\"shj-scroll\">\u003Cdiv class=\"shj-numbers\">\u003Cdiv>1\u003C\u002Fdiv>\u003Cdiv>2\u003C\u002Fdiv>\u003Cdiv>3\u003C\u002Fdiv>\u003Cdiv>4\u003C\u002Fdiv>\u003Cdiv>5\u003C\u002Fdiv>\u003Cdiv>6\u003C\u002Fdiv>\u003Cdiv>7\u003C\u002Fdiv>\u003Cdiv>8\u003C\u002Fdiv>\u003Cdiv>9\u003C\u002Fdiv>\u003Cdiv>10\u003C\u002Fdiv>\u003Cdiv>11\u003C\u002Fdiv>\u003Cdiv>12\u003C\u002Fdiv>\u003Cdiv>13\u003C\u002Fdiv>\u003Cdiv>14\u003C\u002Fdiv>\u003Cdiv>15\u003C\u002Fdiv>\u003Cdiv>16\u003C\u002Fdiv>\u003Cdiv>17\u003C\u002Fdiv>\u003Cdiv>18\u003C\u002Fdiv>\u003Cdiv>19\u003C\u002Fdiv>\u003Cdiv>20\u003C\u002Fdiv>\u003Cdiv>21\u003C\u002Fdiv>\u003Cdiv>22\u003C\u002Fdiv>\u003Cdiv>23\u003C\u002Fdiv>\u003Cdiv>24\u003C\u002Fdiv>\u003Cdiv>25\u003C\u002Fdiv>\u003Cdiv>26\u003C\u002Fdiv>\u003C\u002Fdiv>\u003Cdiv class=\"shj-code\">\u003Cspan class=\"shj-cmnt\">\u002F\u002F app\u002Fproduct\u002F[id]\u002Fpage.tsx\n\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">import\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> \u003Cspan class=\"shj-class\">Suspense\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">from\u003C\u002Fspan> \u003Cspan class=\"shj-str\">'react'\u003C\u002Fspan>;\n\u003Cspan class=\"shj-kwd\">import\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> cookies \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">from\u003C\u002Fspan> \u003Cspan class=\"shj-str\">'next\u002Fheaders'\u003C\u002Fspan>;\n\u003Cspan class=\"shj-kwd\">import\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> cacheLife\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> cacheTag \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">from\u003C\u002Fspan> \u003Cspan class=\"shj-str\">'next\u002Fcache'\u003C\u002Fspan>;\n\n\u003Cspan class=\"shj-kwd\">export\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">default\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">async\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">function\u003C\u002Fspan> \u003Cspan class=\"shj-class\">ProductPage\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> params \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">:\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> params\u003Cspan class=\"shj-oper\">:\u003C\u002Fspan> \u003Cspan class=\"shj-class\">Promise\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&lt;\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> id\u003Cspan class=\"shj-type\">: string\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&gt;\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-kwd\">const\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> id \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan> \u003Cspan class=\"shj-oper\">=\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">await\u003C\u002Fspan> params;\n  \u003Cspan class=\"shj-kwd\">return\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\n    \u003Cspan class=\"shj-var\">\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&lt;\u003C\u002Fspan>\u003Cspan class=\"shj-var\">Suspense\u003C\u002Fspan> \u003Cspan class=\"shj-class\">fallback\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">={\u003C\u002Fspan>\u003Cspan class=\"shj-var\">\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&lt;\u003C\u002Fspan>\u003Cspan class=\"shj-var\">div\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&gt;\u003C\u002Fspan>Loading recommendations...\u003Cspan class=\"shj-var\">\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&lt;\u002F\u003C\u002Fspan>\u003Cspan class=\"shj-var\">div\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&gt;\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">}\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&gt;\u003C\u002Fspan>\n      \u003Cspan class=\"shj-var\">\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&lt;\u003C\u002Fspan>\u003Cspan class=\"shj-var\">Recommendations\u003C\u002Fspan> \u003Cspan class=\"shj-class\">productId\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">={\u003C\u002Fspan>id\u003Cspan class=\"shj-oper\">}\u003C\u002Fspan> \u003Cspan class=\"shj-oper\">\u002F&gt;\u003C\u002Fspan>\n    \u003Cspan class=\"shj-var\">\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&lt;\u002F\u003C\u002Fspan>\u003Cspan class=\"shj-var\">Suspense\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&gt;\u003C\u002Fspan>\n  \u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\n\n\u003Cspan class=\"shj-kwd\">async\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">function\u003C\u002Fspan> \u003Cspan class=\"shj-class\">Recommendations\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> productId \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">:\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> productId\u003Cspan class=\"shj-type\">: string\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-kwd\">const\u003C\u002Fspan> sessionId \u003Cspan class=\"shj-oper\">=\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">await\u003C\u002Fspan> \u003Cspan class=\"shj-func\">cookies\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">.\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">get\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-str\">'session-id'\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">?.\u003C\u002Fspan>value \u003Cspan class=\"shj-oper\">??\u003C\u002Fspan> \u003Cspan class=\"shj-str\">'guest'\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-kwd\">const\u003C\u002Fspan> recs \u003Cspan class=\"shj-oper\">=\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">await\u003C\u002Fspan> \u003Cspan class=\"shj-func\">getRecommendations\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>productId\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> sessionId\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-kwd\">return\u003C\u002Fspan> \u003Cspan class=\"shj-var\">\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&lt;\u003C\u002Fspan>\u003Cspan class=\"shj-var\">RecList\u003C\u002Fspan> \u003Cspan class=\"shj-class\">items\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">={\u003C\u002Fspan>recs\u003Cspan class=\"shj-oper\">}\u003C\u002Fspan> \u003Cspan class=\"shj-oper\">\u002F&gt;\u003C\u002Fspan>;\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\n\n\u003Cspan class=\"shj-kwd\">async\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">function\u003C\u002Fspan> \u003Cspan class=\"shj-func\">getRecommendations\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>productId\u003Cspan class=\"shj-type\">: string\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> sessionId\u003Cspan class=\"shj-type\">: string\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-str\">'use cache: private'\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-func\">cacheTag\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-str\">`recommendations-\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">${\u003C\u002Fspan>productId\u003Cspan class=\"shj-kwd\">}\u003C\u002Fspan>\u003Cspan class=\"shj-str\">`\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-func\">cacheLife\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> stale\u003Cspan class=\"shj-oper\">:\u003C\u002Fspan> \u003Cspan class=\"shj-num\">60\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-kwd\">return\u003C\u002Fspan> db\u003Cspan class=\"shj-oper\">.\u003C\u002Fspan>recommendations\u003Cspan class=\"shj-oper\">.\u003C\u002Fspan>\u003Cspan class=\"shj-func\">personalize\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>productId\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> sessionId\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003C\u002Fdiv>\u003C\u002Fdiv>\u003C\u002Fdiv>","\u003Cdiv class=\"shj shj-lang-tsx shj-multiline\" data-lang=\"tsx\">\u003Cdiv class=\"shj-scroll\">\u003Cdiv class=\"shj-numbers\">\u003Cdiv>1\u003C\u002Fdiv>\u003Cdiv>2\u003C\u002Fdiv>\u003Cdiv>3\u003C\u002Fdiv>\u003Cdiv>4\u003C\u002Fdiv>\u003Cdiv>5\u003C\u002Fdiv>\u003Cdiv>6\u003C\u002Fdiv>\u003Cdiv>7\u003C\u002Fdiv>\u003Cdiv>8\u003C\u002Fdiv>\u003Cdiv>9\u003C\u002Fdiv>\u003Cdiv>10\u003C\u002Fdiv>\u003Cdiv>11\u003C\u002Fdiv>\u003Cdiv>12\u003C\u002Fdiv>\u003Cdiv>13\u003C\u002Fdiv>\u003Cdiv>14\u003C\u002Fdiv>\u003Cdiv>15\u003C\u002Fdiv>\u003Cdiv>16\u003C\u002Fdiv>\u003Cdiv>17\u003C\u002Fdiv>\u003Cdiv>18\u003C\u002Fdiv>\u003Cdiv>19\u003C\u002Fdiv>\u003Cdiv>20\u003C\u002Fdiv>\u003C\u002Fdiv>\u003Cdiv class=\"shj-code\">\u003Cspan class=\"shj-cmnt\">\u002F\u002F app\u002Fproduct\u002F[id]\u002Fpage.tsx\n\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">import\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> \u003Cspan class=\"shj-class\">Suspense\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">from\u003C\u002Fspan> \u003Cspan class=\"shj-str\">'react'\u003C\u002Fspan>;\n\u003Cspan class=\"shj-kwd\">import\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> cookies \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">from\u003C\u002Fspan> \u003Cspan class=\"shj-str\">'next\u002Fheaders'\u003C\u002Fspan>;\n\u003Cspan class=\"shj-kwd\">import\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> cacheTag\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> cacheLife \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">from\u003C\u002Fspan> \u003Cspan class=\"shj-str\">'next\u002Fcache'\u003C\u002Fspan>;\n\n\u003Cspan class=\"shj-kwd\">async\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">function\u003C\u002Fspan> \u003Cspan class=\"shj-class\">ProductPrice\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> productId \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">:\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> productId\u003Cspan class=\"shj-type\">: string\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-cmnt\">\u002F\u002F Reading cookies defers this component to request time\n\u003C\u002Fspan>  \u003Cspan class=\"shj-kwd\">const\u003C\u002Fspan> currency \u003Cspan class=\"shj-oper\">=\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">await\u003C\u002Fspan> \u003Cspan class=\"shj-func\">cookies\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">.\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">get\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-str\">'currency'\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">?.\u003C\u002Fspan>value \u003Cspan class=\"shj-oper\">??\u003C\u002Fspan> \u003Cspan class=\"shj-str\">'USD'\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-kwd\">const\u003C\u002Fspan> price \u003Cspan class=\"shj-oper\">=\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">await\u003C\u002Fspan> \u003Cspan class=\"shj-func\">getProductPrice\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>productId\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> currency\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-kwd\">return\u003C\u002Fspan> \u003Cspan class=\"shj-var\">\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&lt;\u003C\u002Fspan>\u003Cspan class=\"shj-var\">div\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&gt;\u003C\u002Fspan>Price: \u003Cspan class=\"shj-oper\">{\u003C\u002Fspan>price\u003Cspan class=\"shj-oper\">}\u003C\u002Fspan> \u003Cspan class=\"shj-oper\">{\u003C\u002Fspan>currency\u003Cspan class=\"shj-oper\">}\u003C\u002Fspan>\u003Cspan class=\"shj-var\">\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&lt;\u002F\u003C\u002Fspan>\u003Cspan class=\"shj-var\">div\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">&gt;\u003C\u002Fspan>;\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\n\n\u003Cspan class=\"shj-kwd\">async\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">function\u003C\u002Fspan> \u003Cspan class=\"shj-func\">getProductPrice\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>productId\u003Cspan class=\"shj-type\">: string\u003C\u002Fspan>\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> currency\u003Cspan class=\"shj-type\">: string\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-str\">'use cache: remote'\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-func\">cacheTag\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-str\">`product-price-\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">${\u003C\u002Fspan>productId\u003Cspan class=\"shj-kwd\">}\u003C\u002Fspan>\u003Cspan class=\"shj-str\">`\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-func\">cacheLife\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan> expire\u003Cspan class=\"shj-oper\">:\u003C\u002Fspan> \u003Cspan class=\"shj-num\">3600\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>; \u003Cspan class=\"shj-cmnt\">\u002F\u002F 1 hour\n\u003C\u002Fspan>\n  \u003Cspan class=\"shj-cmnt\">\u002F\u002F Cached per (productId, currency) — a handful of currencies, not one entry per visitor\n\u003C\u002Fspan>  \u003Cspan class=\"shj-kwd\">return\u003C\u002Fspan> db\u003Cspan class=\"shj-oper\">.\u003C\u002Fspan>products\u003Cspan class=\"shj-oper\">.\u003C\u002Fspan>\u003Cspan class=\"shj-func\">getPrice\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>productId\u003Cspan class=\"shj-oper\">,\u003C\u002Fspan> currency\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>;\n\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003C\u002Fdiv>\u003C\u002Fdiv>\u003C\u002Fdiv>","\u003Cdiv class=\"shj shj-lang-tsx shj-multiline\" data-lang=\"tsx\">\u003Cdiv class=\"shj-scroll\">\u003Cdiv class=\"shj-numbers\">\u003Cdiv>1\u003C\u002Fdiv>\u003Cdiv>2\u003C\u002Fdiv>\u003Cdiv>3\u003C\u002Fdiv>\u003Cdiv>4\u003C\u002Fdiv>\u003Cdiv>5\u003C\u002Fdiv>\u003Cdiv>6\u003C\u002Fdiv>\u003Cdiv>7\u003C\u002Fdiv>\u003Cdiv>8\u003C\u002Fdiv>\u003Cdiv>9\u003C\u002Fdiv>\u003Cdiv>10\u003C\u002Fdiv>\u003Cdiv>11\u003C\u002Fdiv>\u003C\u002Fdiv>\u003Cdiv class=\"shj-code\">\u003Cspan class=\"shj-cmnt\">\u002F\u002F VALID — remote inside a plain cache\n\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">async\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">function\u003C\u002Fspan> \u003Cspan class=\"shj-func\">outerCache\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-str\">'use cache'\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-kwd\">return\u003C\u002Fspan> \u003Cspan class=\"shj-func\">innerRemote\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>; \u003Cspan class=\"shj-cmnt\">\u002F\u002F fine — resolved when deferred to request time\n\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\n\n\u003Cspan class=\"shj-cmnt\">\u002F\u002F INVALID — remote inside private, or private inside remote, throws\n\u003C\u002Fspan>\u003Cspan class=\"shj-kwd\">async\u003C\u002Fspan> \u003Cspan class=\"shj-kwd\">function\u003C\u002Fspan> \u003Cspan class=\"shj-func\">outerPrivate\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan> \u003Cspan class=\"shj-bracket\">{\u003C\u002Fspan>\n  \u003Cspan class=\"shj-str\">'use cache: private'\u003C\u002Fspan>;\n  \u003Cspan class=\"shj-kwd\">return\u003C\u002Fspan> \u003Cspan class=\"shj-func\">innerRemote\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">(\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">)\u003C\u002Fspan>; \u003Cspan class=\"shj-cmnt\">\u002F\u002F Error\n\u003C\u002Fspan>\u003Cspan class=\"shj-bracket\">}\u003C\u002Fspan>\u003C\u002Fdiv>\u003C\u002Fdiv>\u003C\u002Fdiv>","\u003Cdiv class=\"shj shj-lang-text shj-multiline\" data-lang=\"text\">\u003Cdiv class=\"shj-scroll\">\u003Cdiv class=\"shj-numbers\">\u003Cdiv>1\u003C\u002Fdiv>\u003Cdiv>2\u003C\u002Fdiv>\u003Cdiv>3\u003C\u002Fdiv>\u003Cdiv>4\u003C\u002Fdiv>\u003Cdiv>5\u003C\u002Fdiv>\u003Cdiv>6\u003C\u002Fdiv>\u003Cdiv>7\u003C\u002Fdiv>\u003Cdiv>8\u003C\u002Fdiv>\u003Cdiv>9\u003C\u002Fdiv>\u003Cdiv>10\u003C\u002Fdiv>\u003Cdiv>11\u003C\u002Fdiv>\u003Cdiv>12\u003C\u002Fdiv>\u003Cdiv>13\u003C\u002Fdiv>\u003Cdiv>14\u003C\u002Fdiv>\u003Cdiv>15\u003C\u002Fdiv>\u003Cdiv>16\u003C\u002Fdiv>\u003Cdiv>17\u003C\u002Fdiv>\u003Cdiv>18\u003C\u002Fdiv>\u003Cdiv>19\u003C\u002Fdiv>\u003Cdiv>20\u003C\u002Fdiv>\u003Cdiv>21\u003C\u002Fdiv>\u003Cdiv>22\u003C\u002Fdiv>\u003Cdiv>23\u003C\u002Fdiv>\u003Cdiv>24\u003C\u002Fdiv>\u003Cdiv>25\u003C\u002Fdiv>\u003Cdiv>26\u003C\u002Fdiv>\u003Cdiv>27\u003C\u002Fdiv>\u003Cdiv>28\u003C\u002Fdiv>\u003Cdiv>29\u003C\u002Fdiv>\u003Cdiv>30\u003C\u002Fdiv>\u003Cdiv>31\u003C\u002Fdiv>\u003Cdiv>32\u003C\u002Fdiv>\u003Cdiv>33\u003C\u002Fdiv>\u003Cdiv>34\u003C\u002Fdiv>\u003Cdiv>35\u003C\u002Fdiv>\u003C\u002Fdiv>\u003Cdiv class=\"shj-code\">NEXT.JS 16 CACHE DIRECTIVES — WHICH ONE?\n\n                         use cache     use cache: remote   use cache: private\nShared across users?       yes              yes                  no\nCan read cookies\u002Fheaders?  no               no                   yes\nWhere it's stored          in-memory*       remote handler       nowhere durable\nSurvives a deploy?         no               no                   n\u002Fa\nNeeds cacheHandlers?       optional         yes (or platform)    not configurable\nContributes to static shell? yes            when static          never\n\n* or a configured handler — see cacheHandlers\n\nDECISION ORDER (ask in this order, stop at the first \u003Cspan class=\"shj-str\">\"yes\"\u003C\u002Fspan>):\n1. Can I read the runtime value OUTSIDE the cache and pass it in as an argument?\n   → yes: use plain `use cache`. Done — you probably don't need private or remote.\n2. Is the value genuinely personal \u002F per-user, with no low-cardinality dimension\n   to cache on instead?\n   → yes: `use cache: private`. Set cacheLife({ stale: Infinity }) if it's pure\n     within-request dedup and shouldn't shorten the route's client stale time.\n3. Is the value shared across many users, deferred to request time, and worth\n   paying infra + latency for a real cache hit (slow\u002Frate-limited\u002Fexpensive)?\n   → yes: `use cache: remote`, keyed on the LOW-cardinality dimension\n     (currency, locale, category) — never on something unique per request.\n4. Otherwise: plain `use cache` with an explicit cacheLife.\n\nNESTING\n  remote  inside remote   -&gt; OK\n  remote  inside use cache -&gt; OK\n  remote  inside private   -&gt; ERROR\n  private inside remote    -&gt; ERROR\n\nnext.config.ts (required for all three)\n  export default {\n    cacheComponents: true,\n  }\u003C\u002Fdiv>\u003C\u002Fdiv>\u003C\u002Fdiv>",{"locked":18,"total":19,"comments":630},[]]