@@ -271,7 +271,12 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
271
271
}
272
272
273
273
this . captureResponseCacheLastModified ( blob , key , span )
274
- this . captureCacheTags ( blob . value , key )
274
+
275
+ // Next sets a kind/kindHint and fetchUrl for data requests, however fetchUrl was found to be most reliable across versions
276
+ const isDataRequest = Boolean ( context . fetchUrl )
277
+ if ( ! isDataRequest ) {
278
+ this . captureCacheTags ( blob . value , key )
279
+ }
275
280
276
281
switch ( blob . value ?. kind ) {
277
282
case 'FETCH' :
@@ -391,13 +396,17 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
391
396
392
397
const value = this . transformToStorableObject ( data , context )
393
398
394
- // if previous CacheHandler.get call returned null (page was either never rendered or was on-demand revalidated)
395
- // and we didn't yet capture cache tags, we try to get cache tags from freshly produced cache value
396
- this . captureCacheTags ( value , key )
399
+ // Next sets a fetchCache and fetchUrl for data requests, however fetchUrl was found to be most reliable across versions
400
+ const isDataReq = Boolean ( context . fetchUrl )
401
+ if ( ! isDataReq ) {
402
+ // if previous CacheHandler.get call returned null (page was either never rendered or was on-demand revalidated)
403
+ // and we didn't yet capture cache tags, we try to get cache tags from freshly produced cache value
404
+ this . captureCacheTags ( value , key )
405
+ }
397
406
398
407
await this . cacheStore . set ( key , { lastModified, value } , 'blobStore.set' )
399
408
400
- if ( ! data || data ?. kind === 'PAGE' || data ?. kind === 'PAGES' ) {
409
+ if ( ( ! data && ! isDataReq ) || data ?. kind === 'PAGE' || data ?. kind === 'PAGES' ) {
401
410
const requestContext = getRequestContext ( )
402
411
if ( requestContext ?. didPagesRouterOnDemandRevalidate ) {
403
412
// encode here to deal with non ASCII characters in the key
0 commit comments