Hey friend, Did you know there are 4 levels of Caching in Next.js? Next.js caches for different reasons. In today's newsletter, we're diving into the world of Next.js caching โ a powerful feature that can significantly improve your application's performance. But before we dive into the newsletter, Here is a quick annoucement,I'm running a exclusive live workshop on Next.js. It will be 3-4 hours long. I'm ironing out the final details. โYou can check the landing page here โ๏ธ. It will make you a more confident Next.js Dev and will teach you how to build production-ready apps. We won't be shying from complex topics and diving into them all. If you are interested, you can click the below button to join the waitlist.
The waitlist gets first dibs and special launch bonuses and discounts. -- Anyway, back to our newsletter. If you prefer watching a video instead on the 4 Levels of Caching, then check out this video right here โ๏ธ else keep reading. โ ๐ฟ Our Weekly Snack: Caching in Next.jsNext.js offers a multi-layered caching system that helps you deliver content faster to your users. Now, What is Caching? Caching is like having a box of your favorite cookies ๐ช at the ready, so you don't have to wait to bake them every time you want one. โฉ The job of Next.js Caching system is to speed up data retrieval by storing frequently accessed data in a faster location. Let's break down the 4๏ธโฃ key players. Here is a quick diagram, ๐ Request MemoizationImagine your app constantly bombarding the client with the same questions. Request memoization prevents this by caching function calls on the client-side. This means if your app needs the same data twice, it can retrieve it from the cache instead of making another request. We can achieve the same with memoization in React. ๐๏ธ Data CacheThis is where things get interesting ๐ง. Next.js automatically caches data fetched from the server. By default, this cached data can live forever (or at least until the next ice age).โ๏ธ But fear not! You can configure the data cache to revalidate itself at specific intervals, ensuring your users always have the latest information. Additionally, you can completely invalidate cached data if needed. ๐พ Router CacheThis cache, stores the payloads of your React Server Components on the client-side. This way, when users navigate between pages, Next.js can render the page from the cache, reducing the number of requests needed to the server. ๐ Full Route CacheReact Server Component payload split by routes and HTML on the SERVER. It skips sending new requests if RSC Payload is in Router Cache because why would it? A cache's job is to make sure to check if the app has everything it needs so it checks to see if we already have the data. But, if not, it will fetch it. This is what Full Route Cache does. Now, you might be wondering, "Can I turn caching off?"Absolutely! For situations where you need fresh data every single time, Next.js provides the Keeping your cached data fresh is crucial depending on your use case.
Next.js offers the revalidate and revalidatePath functions to invalidate cached data and ensure your users see the latest updates โจ.Want to learn more? Check out my Youtube video which covers the same with in-depth practical examples โ๏ธ. To wrap up, by effectively leveraging Next.js caching, you can create blazing-fast applications that deliver a seamless user experience โก๏ธ. ๐คซ Latest Frontend NewsIf youโve been feeling discouraged about the future of software engineering because of AI products like Devin, you need to watch this video โ๏ธ ๐ค ๐ Chrome added Support for Error.cause in Chrome DevTools, you can view it here โ๏ธ.โ ๐จ Easy-to-use CSS โ๏ธ View Transitions API helpers for Next.js App Router are here. ๐ Exciting news! Next.js 14.2 has arrived. โSupabase is now GA ๐ โ ๐ฎ React 19 is right around the cornerโ Weekly Youtube Videos ๐ฅThe Frontend Developers Toolbox ๐งฐ
|
Join 9200+ subscribers reading by weekly personalized Newsletter that helps developers level up their skills through weekly Frontend and Leadership Snacks. You get a deep dive into a Tech topic, Actionable tips to excel in your career and a toolbox!
Hey Reader, I just got back from Amsterdam after speaking at React Summit and wow, what a week! ๐ณ๐ฑ I gave a talk called React Framework Showdown ๐ฅ, where I pitted Next.js, TanStack Start, and React Router v7 (aka Remix) against each other in a friendly battle. Why those three? Because they're leading the pack when it comes to modern React and honestly, each one brought something wildly different to the table. I'll share the talk when it's live, but for now, letโs hear it from this week's...
Hey Reader, Ever been stuck writing the same SQL queries over and over againโฆ not because theyโre hard, but because someone on your team needed the data and didnโt know how to get it? Iโve been there. Whether itโs marketing asking, โHow many users signed up last week?โ or product wondering, โDid anyone actually use that new feature?โ, the questions are simple but the friction to get answers is very real. So I built something for that. Introducing: the AI Agent that talks directly to your...
Hey Reader, A couple years ago, I realized something unexpected: I was growing faster in my career not by doing more tutorials or chasing the next shiny framework but by finding a mentor. Want to level up your Next.js skills? โ Find a mentor who has shipped production-ready apps. Want to get better at public speaking? โ Find someone whoโs done it before. At one point, I had multiple mentors, each helping me with something specific. Their guidance made all the difference and helped me focus.It...