Skip to main content
StackDevLife
🐛Bug of the DayIntermediateNode.js, HTTP, Browser

API Returns Cached Data Even After Update

~1 min read
🐛TL;DR

Your API returns old data even after updating records due to caching issues in browser, CDN, or server.

The Bug

Updated data is not reflected in UI; old response keeps showing.

Root Cause

Caching at browser, CDN, or API level without proper cache invalidation or headers.

The Fix

You update data successfully, but:

  • UI still shows old response
    Postman shows correct data
    Browser shows stale data

Common mistake:

No cache control headers in API

Fix (Node.js example):

JavaScript
res.set('Cache-Control', 'no-store');

For fetch requests:

JavaScript
fetch('/api/data', { cache: 'no-store'});

Other causes:

  • CDN caching (Cloudflare, Vercel Edge)
  • Browser cache
  • Service workers

Pro Insight:

Always define caching strategy:

  • Dynamic data → no-store
  • Static data → cache
APICachingBugBackendFrontendPerformance
🐛

Get a new Bug of the Day in your inbox

Subscribe to Stack Dev Life — free, no spam, unsubscribe anytime.

Subscribe free →