File tree Expand file tree Collapse file tree 1 file changed +2
-28
lines changed
Expand file tree Collapse file tree 1 file changed +2
-28
lines changed Original file line number Diff line number Diff line change @@ -223,20 +223,6 @@ function isCacheExpired(entry: CacheEntry<any>): boolean {
223223 return timeNow ( ) > entry . expiry ;
224224}
225225
226- /**
227- * Checks if the cache entry is stale based on its timestamp and the stale time.
228- *
229- * @param {CacheEntry<any> } entry - The cache entry to check.
230- * @returns {boolean } - Returns true if the cache entry is stale, false otherwise.
231- */
232- function isCacheStale ( entry : CacheEntry < any > ) : boolean {
233- if ( ! entry . stale ) {
234- return false ;
235- }
236-
237- return timeNow ( ) > entry . stale ;
238- }
239-
240226/**
241227 * Retrieves a cached response from the internal cache using the provided key.
242228 *
@@ -453,27 +439,15 @@ export function getCachedResponse<
453439 }
454440
455441 const isExpired = isCacheExpired ( entry ) ;
456- const isStale = isCacheStale ( entry ) ;
457442
458443 // If completely expired, delete and return null
459444 if ( isExpired ) {
460445 deleteCache ( cacheKey ) ;
461446 return null ;
462447 }
463448
464- // If fresh (not stale), return immediately
465- if ( ! isStale ) {
466- return entry . data ;
467- }
468-
469- // SWR: Data is stale but not expired
470- if ( isStale && ! isExpired ) {
471- // Triggering background revalidation here could cause race conditions
472- // So we return stale data immediately and leave it up to implementers to handle revalidation
473- return entry . data ;
474- }
475-
476- return null ;
449+ // Return data whether fresh or stale (SWR: serve stale, revalidation is timer-driven)
450+ return entry . data ;
477451}
478452
479453/**
You can’t perform that action at this time.
0 commit comments