@@ -295,22 +295,8 @@ export default class Cache {
295
295
break ;
296
296
}
297
297
}
298
- if (
299
- globalThis . openNextConfig . dangerous ?. disableTagCache ||
300
- globalThis . tagCache . mode === "nextMode"
301
- ) {
302
- return ;
303
- }
304
- // Write derivedTags to dynamodb
305
- // If we use an in house version of getDerivedTags in build we should use it here instead of next's one
306
- const derivedTags : string [ ] =
307
- data ?. kind === "FETCH"
308
- ? ( ctx ?. tags ?? data ?. data ?. tags ?? [ ] ) // before version 14 next.js used data?.data?.tags so we keep it for backward compatibility
309
- : data ?. kind === "PAGE"
310
- ? ( data . headers ?. [ "x-next-cache-tags" ] ?. split ( "," ) ?? [ ] )
311
- : [ ] ;
312
- debug ( "derivedTags" , derivedTags ) ;
313
- await this . updateTagsOnSet ( key , derivedTags ) ;
298
+
299
+ await this . updateTagsOnSet ( key , data , ctx ) ;
314
300
debug ( "Finished setting cache" ) ;
315
301
} catch ( e ) {
316
302
error ( "Failed to set cache" , e ) ;
@@ -414,13 +400,28 @@ export default class Cache {
414
400
}
415
401
}
416
402
417
- private async updateTagsOnSet ( key : string , derivedTags : string [ ] ) {
403
+ private async updateTagsOnSet (
404
+ key : string ,
405
+ data ?: IncrementalCacheValue ,
406
+ ctx ?: IncrementalCacheContext ,
407
+ ) {
418
408
if (
419
409
globalThis . openNextConfig . dangerous ?. disableTagCache ||
420
410
globalThis . tagCache . mode === "nextMode"
421
411
) {
422
412
return ;
423
413
}
414
+
415
+ // Write derivedTags to the tag cache
416
+ // If we use an in house version of getDerivedTags in build we should use it here instead of next's one
417
+ const derivedTags : string [ ] =
418
+ data ?. kind === "FETCH"
419
+ ? ( ctx ?. tags ?? data ?. data ?. tags ?? [ ] ) // before version 14 next.js used data?.data?.tags so we keep it for backward compatibility
420
+ : data ?. kind === "PAGE"
421
+ ? ( data . headers ?. [ "x-next-cache-tags" ] ?. split ( "," ) ?? [ ] )
422
+ : [ ] ;
423
+ debug ( "derivedTags" , derivedTags ) ;
424
+
424
425
// Get all tags stored in dynamodb for the given key
425
426
// If any of the derived tags are not stored in dynamodb for the given key, write them
426
427
const storedTags = await globalThis . tagCache . getByPath ( key ) ;
0 commit comments