@@ -11,6 +11,7 @@ import { type Span } from '@opentelemetry/api'
11
11
import type { PrerenderManifest } from 'next/dist/build/index.js'
12
12
import { NEXT_CACHE_TAGS_HEADER } from 'next/dist/lib/constants.js'
13
13
14
+ import { name as nextRuntimePkgName , version as nextRuntimePkgVersion } from '../../../package.json'
14
15
import {
15
16
type CacheHandlerContext ,
16
17
type CacheHandlerForMultipleVersions ,
@@ -30,6 +31,8 @@ type TagManifest = { revalidatedAt: number }
30
31
31
32
type TagManifestBlobCache = Record < string , Promise < TagManifest > >
32
33
34
+ const purgeCacheUserAgent = `${ nextRuntimePkgName } @${ nextRuntimePkgVersion } `
35
+
33
36
export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
34
37
options : CacheHandlerContext
35
38
revalidatedTags : string [ ]
@@ -347,12 +350,14 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
347
350
const tag = `_N_T_${ key === '/index' ? '/' : encodeURI ( key ) } `
348
351
getLogger ( ) . debug ( `Purging CDN cache for: [${ tag } ]` )
349
352
requestContext . trackBackgroundWork (
350
- purgeCache ( { tags : tag . split ( / , | % 2 c / gi) } ) . catch ( ( error ) => {
351
- // TODO: add reporting here
352
- getLogger ( )
353
- . withError ( error )
354
- . error ( `[NetlifyCacheHandler]: Purging the cache for tag ${ tag } failed` )
355
- } ) ,
353
+ purgeCache ( { tags : tag . split ( / , | % 2 c / gi) , userAgent : purgeCacheUserAgent } ) . catch (
354
+ ( error ) => {
355
+ // TODO: add reporting here
356
+ getLogger ( )
357
+ . withError ( error )
358
+ . error ( `[NetlifyCacheHandler]: Purging the cache for tag ${ tag } failed` )
359
+ } ,
360
+ ) ,
356
361
)
357
362
}
358
363
}
@@ -393,7 +398,7 @@ export class NetlifyCacheHandler implements CacheHandlerForMultipleVersions {
393
398
} ) ,
394
399
)
395
400
396
- await purgeCache ( { tags } ) . catch ( ( error ) => {
401
+ await purgeCache ( { tags, userAgent : purgeCacheUserAgent } ) . catch ( ( error ) => {
397
402
// TODO: add reporting here
398
403
getLogger ( )
399
404
. withError ( error )
0 commit comments