<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Mohamed Hossam</title>
    <description>The latest articles on Forem by Mohamed Hossam (@mohamedhossam1).</description>
    <link>https://forem.com/mohamedhossam1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3925663%2F62fc2bdd-2155-414f-8200-4adf86e859bb.png</url>
      <title>Forem: Mohamed Hossam</title>
      <link>https://forem.com/mohamedhossam1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/mohamedhossam1"/>
    <language>en</language>
    <item>
      <title>I Built a Production-Grade Next.js Caching Skill Because the Docs Let Me Down</title>
      <dc:creator>Mohamed Hossam</dc:creator>
      <pubDate>Mon, 11 May 2026 19:14:54 +0000</pubDate>
      <link>https://forem.com/mohamedhossam1/i-built-a-production-grade-nextjs-caching-skill-because-the-docs-let-me-down-50k4</link>
      <guid>https://forem.com/mohamedhossam1/i-built-a-production-grade-nextjs-caching-skill-because-the-docs-let-me-down-50k4</guid>
      <description>&lt;p&gt;The Next.js docs cover caching basics. They don't tell you what to do when your page has dynamic routes, search params, or personalized content.&lt;/p&gt;

&lt;p&gt;I ran into this firsthand. I was building a production app and kept asking myself:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the page has &lt;code&gt;searchParams&lt;/code&gt;, does &lt;code&gt;"use cache"&lt;/code&gt; still work?&lt;/li&gt;
&lt;li&gt;Where do I put &lt;code&gt;cookies()&lt;/code&gt; if I can't call it inside a cached function?&lt;/li&gt;
&lt;li&gt;How do I invalidate one product without nuking the entire cache?&lt;/li&gt;
&lt;li&gt;Should the page component fetch data or just orchestrate?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The docs had none of this. So I figured it out myself — through trial, error, and a lot of broken builds.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;I turned everything I learned into an agent skill: &lt;strong&gt;nextjs-cache-architecture&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It's not a tutorial. It's a set of rules and templates your AI agent loads once and applies to your actual codebase — replacing placeholders with your real entity and collection names.&lt;/p&gt;

&lt;p&gt;The skill covers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A 5-layer mental model (static shell → cached content → entity pages → personalized content → invalidation)&lt;/li&gt;
&lt;li&gt;A centralized tag registry in &lt;code&gt;lib/cache/tags.ts&lt;/code&gt; — raw tag strings never written anywhere else&lt;/li&gt;
&lt;li&gt;A revalidation utility layer in &lt;code&gt;lib/cache/revalidate.ts&lt;/code&gt; — &lt;code&gt;updateTag()&lt;/code&gt; called from one place only&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;SuspenseOnSearchParams&lt;/code&gt; — a wrapper that fixes Suspense not re-triggering on client-side navigation when only search params change&lt;/li&gt;
&lt;li&gt;Personalized content pattern — read &lt;code&gt;cookies()&lt;/code&gt; outside the cache boundary, pass primitives as props&lt;/li&gt;
&lt;li&gt;The single question that decides whether you need an entity tag factory at all&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why an agent skill and not a blog post
&lt;/h2&gt;

&lt;p&gt;A blog post gives you concepts. A skill gives your AI agent executable rules it can apply to your project right now, in any session, without you re-explaining anything.&lt;/p&gt;

&lt;p&gt;Next.js caching is architecture — you need to design it upfront, not retrofit it. This skill enforces that from the first line of code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx skills add mohamed-hossam1/nextjs-cache-architecture
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then invoke it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/nextjs-cache-architecture
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Works with Claude Code, Cursor, Codex, Gemini CLI, and 50+ other agents.&lt;/p&gt;

&lt;p&gt;Feedback welcome — especially if you've hit caching edge cases the skill doesn't cover yet.&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
