You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -211,19 +211,19 @@ export default class RedisStringsHandler {
211
211
key: string,
212
212
ctx:
213
213
|{
214
-
kind: 'APP_ROUTE'|'APP_PAGE';
215
-
isRoutePPREnabled: boolean;
216
-
isFallback: boolean;
217
-
}
214
+
kind: 'APP_ROUTE'|'APP_PAGE';
215
+
isRoutePPREnabled: boolean;
216
+
isFallback: boolean;
217
+
}
218
218
|{
219
-
kind: 'FETCH';
220
-
revalidate: number;
221
-
fetchUrl: string;
222
-
fetchIdx: number;
223
-
tags: string[];
224
-
softTags: string[];
225
-
isFallback: boolean;
226
-
},
219
+
kind: 'FETCH';
220
+
revalidate: number;
221
+
fetchUrl: string;
222
+
fetchIdx: number;
223
+
tags: string[];
224
+
softTags: string[];
225
+
isFallback: boolean;
226
+
},
227
227
): Promise<CacheEntry|null>{
228
228
if(
229
229
ctx.kind!=='APP_ROUTE'&&
@@ -310,9 +310,11 @@ export default class RedisStringsHandler {
310
310
returncacheEntry;
311
311
}
312
312
313
-
// This code checks if any of the cache tags associated with this entry have been revalidated
314
-
// since the entry was last modified. If any tag was revalidated more recently than the entry's
315
-
// lastModified timestamp, then the cached content is considered stale and should be removed.
313
+
// INFO: implicit tags (revalidate of nested fetch in api route/page on revalidatePath call of the page/api route). See revalidateTag() for more information
314
+
//
315
+
// This code checks if any of the cache tags associated with this entry (normally the internal tag of the parent page/api route containing the fetch request)
316
+
// have been revalidated since the entry was last modified. If any tag was revalidated more recently than the entry's
317
+
// lastModified timestamp, then the cached content is considered stale (therefore return null) and should be removed.
316
318
for(consttagofcombinedTags){
317
319
// Get the last revalidation time for this tag from our revalidatedTagsMap
@@ -444,8 +446,8 @@ export default class RedisStringsHandler {
444
446
// Constructing the expire time for the cache entry
445
447
constexpireAt=
446
448
ctx.revalidate&&
447
-
Number.isSafeInteger(ctx.revalidate)&&
448
-
ctx.revalidate>0
449
+
Number.isSafeInteger(ctx.revalidate)&&
450
+
ctx.revalidate>0
449
451
? this.estimateExpireAge(ctx.revalidate)
450
452
: this.estimateExpireAge(this.defaultStaleAge);
451
453
@@ -465,6 +467,8 @@ export default class RedisStringsHandler {
465
467
'RedisStringsHandler.set() will set the following serializedCacheEntry',
466
468
this.keyPrefix,
467
469
key,
470
+
data,
471
+
ctx,
468
472
serializedCacheEntry?.substring(0,200),
469
473
expireAt,
470
474
);
@@ -510,43 +514,15 @@ export default class RedisStringsHandler {
510
514
// find all keys that are related to this tag
511
515
constkeysToDelete: Set<string>=newSet();
512
516
513
-
// TODO right now this code is only tested for calls with revalidatePath. We need to test this code for calls with revalidateTag as well
514
-
// a call to revalidatePath will result in revalidateTag(_N_T_...) -> therefore we could check of tagOrTags.startsWith(_N_T_) to only execute this code for revalidatePath calls
515
-
516
517
for(consttagoftags){
517
-
// If a page has a fetch request inside. This fetch request needs to be revalidated as well. This is done by the following code
518
-
// sharedTags are containing all directly dependent tags. Need to find out the keys for these tags
519
-
constsharedTags=this.sharedTagsMap.get(
520
-
tag.replace(NEXT_CACHE_IMPLICIT_TAG_ID,''),
521
-
);
522
-
for(constsharedTagofsharedTags||[]){
523
-
// Implicit tags are not stored in cache therefore we can ignore them and only look at the non-implicit tags
// TODO check if this can be deleted with the new logic --> Seems like it can not be deleted --> above implementation only works for pages and not for api routes
548
-
// For Next.js implicit tags (route-based), store the revalidation timestamp
549
-
// This is used to track when routes were last invalidated
518
+
// INFO: implicit tags (revalidate of nested fetch in api route/page on revalidatePath call of the page/api route)
519
+
//
520
+
// Invalidation logic for fetch requests that are related to a invalidated page.
521
+
// revalidateTag is called for the page tag (_N_T_...) and the fetch request needs to be invalidated as well
522
+
// unfortunately this is not possible since the revalidateTag is not called with any data that would allow us to find the cache entry of the fetch request
523
+
// in case of a fetch request get method call, the get method of the cache handler is called with some information about the pages/routes the fetch request is inside
524
+
// therefore we only mark the page/route as stale here (with help of the revalidatedTagsMap)
525
+
// and delete the cache entry of the fetch request on the next request to the get function
0 commit comments