Posts

Showing posts from August, 2025

Next.js API Caching Explained: Why Your Data Might Be Stale (and How to Fix It)

Image
ЁЯзР Introduction Next JS API Calling that gives Cached Data Instead of updated DB Data If you’ve ever built a Next.js application or any application and noticed your API is returning old or outdated data , even though the database has been updated, you’re not alone. This is a common confusion for developers new to Next.js’ server-side fetch caching . In this article, we’ll explore: Why this happens in both development and production. How Next.js fetch caching works. How to disable it when you need fresh data. The SEO impact of different fetching methods. ЁЯТб The Problem Imagine you have an API route: pages/api/setting/notifications.ts Copy export default async function handler ( req, res ) { const settings = await db. query ( "SELECT * FROM notification_settings LIMIT 1" ); res. json ({ data : settings }); } ...

Pageviews