@@ -7,6 +7,8 @@ import { getTagsFromValue, hasBeenRevalidated, writeTags } from "utils/cache";
77import { isBinaryContentType } from "../utils/binary" ;
88import { debug , error , warn } from "./logger" ;
99
10+ export const SOFT_TAG_PREFIX = "_N_T_/" ;
11+
1012function isFetchCache (
1113 options ?:
1214 | boolean
@@ -75,15 +77,15 @@ export default class Cache {
7577 // Then we need to find the path for the given key
7678 const path = softTags ?. find (
7779 ( tag ) =>
78- tag . startsWith ( "_N_T_/" ) &&
80+ tag . startsWith ( SOFT_TAG_PREFIX ) &&
7981 ! tag . endsWith ( "layout" ) &&
8082 ! tag . endsWith ( "page" ) ,
8183 ) ;
8284 if ( path ) {
8385 const hasPathBeenUpdated = cachedEntry . shouldBypassTagCache
8486 ? false
8587 : await hasBeenRevalidated (
86- path . replace ( "_N_T_/" , "" ) ,
88+ path . replace ( SOFT_TAG_PREFIX , "" ) ,
8789 [ ] ,
8890 cachedEntry ,
8991 ) ;
@@ -356,11 +358,11 @@ export default class Cache {
356358 } ) ) ;
357359
358360 // If the tag is a soft tag, we should also revalidate the hard tags
359- if ( tag . startsWith ( "_N_T_/" ) ) {
361+ if ( tag . startsWith ( SOFT_TAG_PREFIX ) ) {
360362 for ( const path of paths ) {
361363 // We need to find all hard tags for a given path
362364 const _tags = await globalThis . tagCache . getByPath ( path ) ;
363- const hardTags = _tags . filter ( ( t ) => ! t . startsWith ( "_N_T_/" ) ) ;
365+ const hardTags = _tags . filter ( ( t ) => ! t . startsWith ( SOFT_TAG_PREFIX ) ) ;
364366 // For every hard tag, we need to find all paths and revalidate them
365367 for ( const hardTag of hardTags ) {
366368 const _paths = await globalThis . tagCache . getByTag ( hardTag ) ;
@@ -384,7 +386,7 @@ export default class Cache {
384386 new Set (
385387 toInsert
386388 // We need to filter fetch cache key as they are not in the CDN
387- . filter ( ( t ) => t . tag . startsWith ( "_N_T_/" ) )
389+ . filter ( ( t ) => t . tag . startsWith ( SOFT_TAG_PREFIX ) )
388390 . map ( ( t ) => `/${ t . path } ` ) ,
389391 ) ,
390392 ) ;
0 commit comments