The Silent Speed Killer: Mastering Next.js Caching
If you've built anything with the Next.js App Router, you've probably hit that moment where your app feels sluggish despite having a lighthouse score of 100. It took me an embarrassingly long time to realize that the culprit was often right under my nose: the caching layer.
Next.js caching is aggressive by default. It assumes you want everything static unless told otherwise. The "aha!" moment for me was realizing I needed to actively manage revalidate times and explicitly define what data changes frequently.
Stop fighting the cache. Instead, map out your data dependencies before writing the component. When does this specific piece of data actually become stale? Once I started defining caching strategies component by component (using next: { revalidate: 3600 } or no-store when necessary), the random sluggishness disappeared.
Performance isn't just about small bundles; it's about predicting when your user needs fresh data versus when yesterday's news will do just fine.