File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed
packages/cloudflare/src/api Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,23 @@ export const CACHE_ASSET_DIR = "cnd-cgi/_next_cache";
77
88export const STATUS_DELETED = 1 ;
99
10+ // https://github.com/vercel/next.js/blob/9a1cd356/packages/next/src/server/response-cache/types.ts#L26-L38
11+ export type CachedFetchValue = {
12+ kind : "FETCH" ;
13+ data : {
14+ headers : { [ k : string ] : string } ;
15+ body : string ;
16+ url : string ;
17+ status ?: number ;
18+ // field used by older versions of Next.js (see: https://github.com/vercel/next.js/blob/fda1ecc/packages/next/src/server/response-cache/types.ts#L23)
19+ tags ?: string [ ] ;
20+ } ;
21+ // tags are only present with file-system-cache
22+ // fetch cache stores tags outside of cache entry
23+ tags ?: string [ ] ;
24+ revalidate : number ;
25+ } ;
26+
1027/**
1128 * Open Next cache based on cloudflare KV and Assets.
1229 *
@@ -63,12 +80,9 @@ class Cache implements IncrementalCache {
6380 }
6481 }
6582
66- const entryValue = entry ?. value as Record < string , unknown > ;
67- if ( entryValue . kind === "FETCH" ) {
68- const data = ( entryValue . data as Record < string , string > | undefined ) ?. headers as
69- | Record < string , string >
70- | undefined ;
71- const expires = data ?. expires ;
83+ const entryValue = entry ?. value as CachedFetchValue | undefined ;
84+ if ( entryValue ?. kind === "FETCH" ) {
85+ const expires = entryValue . data . headers ?. expires ;
7286 const expiresTime = new Date ( expires as string ) . getTime ( ) ;
7387 if ( ! isNaN ( expiresTime ) && expiresTime <= new Date ( ) . getTime ( ) ) {
7488 this . debug ( `found expired entry (expire time: ${ expires } )` ) ;
You can’t perform that action at this time.
0 commit comments